Browse Source

Merge branch 'develop'

marinofaggiana 3 years ago
parent
commit
f52a4acf2e
100 changed files with 3638 additions and 2572 deletions
  1. 1 1
      Cartfile
  2. 9 8
      File Provider Extension/FileProviderData.swift
  3. 1 1
      File Provider Extension/FileProviderDomain.swift
  4. 1 0
      File Provider Extension/FileProviderEnumerator.swift
  5. 1 0
      File Provider Extension/FileProviderExtension+Actions.swift
  6. 1 0
      File Provider Extension/FileProviderExtension+Thumbnail.swift
  7. 5 7
      File Provider Extension/FileProviderExtension.swift
  8. 4 0
      File Provider Extension/FileProviderItem.swift
  9. 2 0
      File Provider Extension/FileProviderUtility.swift
  10. 247 182
      Nextcloud.xcodeproj/project.pbxproj
  11. 13 13
      Nextcloud.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
  12. 1 1
      Nextcloud.xcodeproj/xcshareddata/xcschemes/File Provider Extension.xcscheme
  13. 1 1
      Nextcloud.xcodeproj/xcshareddata/xcschemes/Nextcloud.xcscheme
  14. 8 4
      Nextcloud.xcodeproj/xcshareddata/xcschemes/Share.xcscheme
  15. 1 0
      Notification Service Extension/NotificationService.swift
  16. 0 38
      Share/CCCellShareExt.h
  17. 0 45
      Share/CCCellShareExt.m
  18. 0 65
      Share/CCCellShareExt.xib
  19. 0 205
      Share/CCloadItemData.swift
  20. 216 68
      Share/MainInterface.storyboard
  21. 0 65
      Share/NCSelectDestination.h
  22. 0 320
      Share/NCSelectDestination.m
  23. 0 100
      Share/NCSelectDestination.storyboard
  24. 903 0
      Share/NCShareExtension.swift
  25. 1 1
      Share/Share-Bridging-Header.h
  26. 0 42
      Share/ShareViewController.h
  27. 0 458
      Share/ShareViewController.m
  28. 42 29
      iOSClient/Account Request/NCAccountRequest.storyboard
  29. 58 28
      iOSClient/Account Request/NCAccountRequest.swift
  30. 5 5
      iOSClient/Activity/NCActivity.storyboard
  31. 36 23
      iOSClient/Activity/NCActivity.swift
  32. 104 59
      iOSClient/AppDelegate.swift
  33. 257 0
      iOSClient/BackgroundImageColor/NCBackgroundImageColor.storyboard
  34. 302 0
      iOSClient/BackgroundImageColor/NCBackgroundImageColor.swift
  35. 6 0
      iOSClient/Brand/Background.xcassets/Contents.json
  36. 0 1
      iOSClient/Brand/Intro/NCIntroCollectionViewCell.swift
  37. 3 1
      iOSClient/Brand/Intro/NCIntroViewController.swift
  38. 179 55
      iOSClient/Brand/NCBrand.swift
  39. 6 6
      iOSClient/BrowserWeb/NCBrowserWeb.storyboard
  40. 5 2
      iOSClient/BrowserWeb/NCBrowserWeb.swift
  41. 7 7
      iOSClient/Data/NCDataSource.swift
  42. 20 1
      iOSClient/Data/NCDatabase.swift
  43. 1 1
      iOSClient/Data/NCElementsJSON.swift
  44. 135 32
      iOSClient/Data/NCManageDatabase.swift
  45. 22 4
      iOSClient/Diagnostics/NCCapabilitiesViewController.storyboard
  46. 41 39
      iOSClient/Diagnostics/NCCapabilitiesViewController.swift
  47. 48 28
      iOSClient/EmptyView/NCEmptyDataSet.swift
  48. 8 7
      iOSClient/EmptyView/NCEmptyView.xib
  49. 13 7
      iOSClient/Extensions/NSMutableAttributedString+Extensions.swift
  50. 1 0
      iOSClient/Extensions/NSNotificationCenter+MainThread.h
  51. 1 0
      iOSClient/Extensions/NotificationCenter+MainThread.swift
  52. 1 0
      iOSClient/Extensions/String+Extensions.swift
  53. 31 0
      iOSClient/Extensions/UIColor+Extensions.swift
  54. 1 0
      iOSClient/Extensions/UIImage+Extensions.swift
  55. 28 7
      iOSClient/Extensions/UIImage+animatedGIF.h
  56. 24 1
      iOSClient/Extensions/UIImage+animatedGIF.m
  57. 4 2
      iOSClient/Favorites/NCFavorite.swift
  58. 8 5
      iOSClient/FileViewInFolder/NCFileViewInFolder.swift
  59. 6 4
      iOSClient/Files/NCFiles.swift
  60. 26 0
      iOSClient/Images.xcassets/back.imageset/Contents.json
  61. BIN
      iOSClient/Images.xcassets/back.imageset/back-1.png
  62. BIN
      iOSClient/Images.xcassets/back.imageset/back-2.png
  63. BIN
      iOSClient/Images.xcassets/back.imageset/back.png
  64. 5 5
      iOSClient/Images.xcassets/certificate.imageset/Contents.json
  65. 1 0
      iOSClient/Images.xcassets/certificate.imageset/certificate.svg
  66. 0 51
      iOSClient/Images.xcassets/exit.imageset/exit.pdf
  67. BIN
      iOSClient/Images.xcassets/exitCircle.imageset/exitCircle.pdf
  68. 6 6
      iOSClient/Images.xcassets/gitHub.imageset/Contents.json
  69. BIN
      iOSClient/Images.xcassets/gitHub.imageset/github.png
  70. BIN
      iOSClient/Images.xcassets/gitHub.imageset/github@2x.png
  71. BIN
      iOSClient/Images.xcassets/gitHub.imageset/github@3x.png
  72. 5 5
      iOSClient/Images.xcassets/lock-question.imageset/Contents.json
  73. 1 0
      iOSClient/Images.xcassets/lock-question.imageset/lock-question.svg
  74. 12 0
      iOSClient/Images.xcassets/mac.imageset/Contents.json
  75. BIN
      iOSClient/Images.xcassets/mac.imageset/mac.png
  76. BIN
      iOSClient/Images.xcassets/moreAvatar.imageset/moreAvatar.png
  77. BIN
      iOSClient/Images.xcassets/moreAvatar.imageset/moreAvatar@2x.png
  78. BIN
      iOSClient/Images.xcassets/moreAvatar.imageset/moreAvatar@3x.png
  79. 26 0
      iOSClient/Images.xcassets/shield.checkerboard.imageset/Contents.json
  80. BIN
      iOSClient/Images.xcassets/shield.checkerboard.imageset/privacy.png
  81. BIN
      iOSClient/Images.xcassets/shield.checkerboard.imageset/privacy@2x.png
  82. BIN
      iOSClient/Images.xcassets/shield.checkerboard.imageset/privacy@3x.png
  83. 8 6
      iOSClient/Login/NCAppConfigView.swift
  84. 17 4
      iOSClient/Login/NCLogin.storyboard
  85. 107 13
      iOSClient/Login/NCLogin.swift
  86. 1 1
      iOSClient/Login/NCLoginQRCode.swift
  87. 16 11
      iOSClient/Login/NCLoginWeb.swift
  88. 0 60
      iOSClient/Main/ActionSheetHeaderView/NCActionSheetHeader.swift
  89. 0 51
      iOSClient/Main/ActionSheetHeaderView/NCActionSheetHeaderView.xib
  90. 42 28
      iOSClient/Main/AudioRecorder/NCAudioRecorderViewController.swift
  91. 345 208
      iOSClient/Main/Collection Common/NCCollectionViewCommon.swift
  92. 9 1
      iOSClient/Main/Collection Common/NCGridCell.swift
  93. 2 3
      iOSClient/Main/Collection Common/NCGridCell.xib
  94. 17 6
      iOSClient/Main/Collection Common/NCListCell.swift
  95. 4 3
      iOSClient/Main/Collection Common/NCListCell.xib
  96. 51 44
      iOSClient/Main/Create cloud/NCCreateFormUploadAssets.swift
  97. 28 12
      iOSClient/Main/Create cloud/NCCreateFormUploadConflict.storyboard
  98. 46 34
      iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift
  99. 1 1
      iOSClient/Main/Create cloud/NCCreateFormUploadConflictCell.swift
  100. 43 40
      iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

+ 1 - 1
Cartfile

@@ -6,6 +6,6 @@ github "xmartlabs/XLForm" ~> 4.1
 github "AssistoLab/DropDown" "v2.3.13"
 
 github "https://github.com/marinofaggiana/KTVHTTPCache" "2.0.2"
-github "https://github.com/marinofaggiana/TOPasscodeViewController" "0.0.8"
+github "https://github.com/marinofaggiana/TOPasscodeViewController" "0.0.10"
 github "https://github.com/marinofaggiana/OpenSSL" "master"
 github "https://github.com/marinofaggiana/ChromaColorPicker" "master"

+ 9 - 8
File Provider Extension/FileProviderData.swift

@@ -21,6 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+import UIKit
 import NCCommunication
 
 class fileProviderData: NSObject {
@@ -84,18 +85,18 @@ class fileProviderData: NSObject {
         // NO DOMAIN -> Set default account
         if domain == nil {
             
-            guard let accountActive = NCManageDatabase.shared.getAccountActive() else { return nil }
-            let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: accountActive.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
-            let webDav = NCUtilityFileSystem.shared.getWebDAV(account: accountActive.account)
+            guard let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return nil }
+            let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: activeAccount.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
+            let webDav = NCUtilityFileSystem.shared.getWebDAV(account: activeAccount.account)
             
-            account = accountActive.account
-            accountUrlBase = accountActive.urlBase
-            homeServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: accountActive.urlBase, account: accountActive.account)
+            account = activeAccount.account
+            accountUrlBase = activeAccount.urlBase
+            homeServerUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, account: activeAccount.account)
                         
-            NCCommunicationCommon.shared.setup(account: accountActive.account, user: accountActive.user, userId: accountActive.userId, password: CCUtility.getPassword(accountActive.account), urlBase: accountActive.urlBase, userAgent: CCUtility.getUserAgent(), webDav: webDav, dav: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
+            NCCommunicationCommon.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account), urlBase: activeAccount.urlBase, userAgent: CCUtility.getUserAgent(), webDav: webDav, dav: nil, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
             NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate
             
-            return tableAccount.init(value: accountActive)
+            return tableAccount.init(value: activeAccount)
         }
         
         // DOMAIN

+ 1 - 1
File Provider Extension/FileProviderDomain.swift

@@ -21,7 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 
 class FileProviderDomain: NSObject {
     

+ 1 - 0
File Provider Extension/FileProviderEnumerator.swift

@@ -21,6 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+import UIKit
 import FileProvider
 import NCCommunication
 

+ 1 - 0
File Provider Extension/FileProviderExtension+Actions.swift

@@ -21,6 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+import UIKit
 import FileProvider
 import NCCommunication
 

+ 1 - 0
File Provider Extension/FileProviderExtension+Thumbnail.swift

@@ -21,6 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+import UIKit
 import FileProvider
 import NCCommunication
 

+ 5 - 7
File Provider Extension/FileProviderExtension.swift

@@ -21,6 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+import UIKit
 import FileProvider
 import NCCommunication
 import Alamofire
@@ -144,12 +145,9 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
                 
         var url = fileProviderData.shared.fileProviderManager.documentStorageURL.appendingPathComponent(identifier.rawValue, isDirectory: true)
         
-        if item.typeIdentifier == (kUTTypeFolder as String) {
-            url = url.appendingPathComponent(item.filename, isDirectory:true)
-        } else {
-            url = url.appendingPathComponent(item.filename, isDirectory:false)
-        }
-        
+        // (fix copy/paste directory -> isDirectory = false)
+        url = url.appendingPathComponent(item.filename, isDirectory:false)
+    
         return url
     }
     
@@ -349,7 +347,7 @@ class FileProviderExtension: NSFileProviderExtension, NCNetworkingDelegate {
                 
                 fileURL.stopAccessingSecurityScopedResource()
                                 
-                let metadata = NCManageDatabase.shared.createMetadata(account: fileProviderData.shared.account, fileName: fileName, fileNameView: fileName, ocId: ocIdTemp, serverUrl: tableDirectory.serverUrl, urlBase: fileProviderData.shared.accountUrlBase, url: "", contentType: "", livePhoto: false, chunk: false)
+                let metadata = NCManageDatabase.shared.createMetadata(account: fileProviderData.shared.account, fileName: fileName, fileNameView: fileName, ocId: ocIdTemp, serverUrl: tableDirectory.serverUrl, urlBase: fileProviderData.shared.accountUrlBase, url: "", contentType: "", livePhoto: false)
                 metadata.session = NCNetworking.shared.sessionIdentifierBackgroundExtension
                 metadata.size = size
                 metadata.status = NCGlobal.shared.metadataStatusUploading

+ 4 - 0
File Provider Extension/FileProviderItem.swift

@@ -21,6 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+import UIKit
 import FileProvider
 import NCCommunication
 
@@ -99,6 +100,9 @@ class FileProviderItem: NSObject, NSFileProviderItem {
     }
     
     var isDownloaded: Bool {
+        if metadata.directory {
+            return true
+        }
         if CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) {
             return true
         } else {

+ 2 - 0
File Provider Extension/FileProviderUtility.swift

@@ -21,6 +21,8 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+import UIKit
+
 class fileProviderUtility: NSObject {
     static let shared: fileProviderUtility = {
         let instance = fileProviderUtility()

File diff suppressed because it is too large
+ 247 - 182
Nextcloud.xcodeproj/project.pbxproj


+ 13 - 13
Nextcloud.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

@@ -42,8 +42,8 @@
         "repositoryURL": "https://github.com/firebase/firebase-ios-sdk",
         "state": {
           "branch": null,
-          "revision": "22d785016bf9b9a5d425597bf4a0ddd4cb158e5f",
-          "version": "8.1.0"
+          "revision": "b97bfcd2e5eecc7aa7e1aeb27d097d610876cf93",
+          "version": "7.11.1"
         }
       },
       {
@@ -60,8 +60,8 @@
         "repositoryURL": "https://github.com/google/GoogleAppMeasurement.git",
         "state": {
           "branch": null,
-          "revision": "48fcea0c0a74fc89131696aa995043eaa971ccb1",
-          "version": "8.0.0"
+          "revision": "22cb3ab5588200b210ae01e42665f52ac4e8ad28",
+          "version": "7.11.1"
         }
       },
       {
@@ -102,11 +102,11 @@
       },
       {
         "package": "NCCommunication",
-        "repositoryURL": "https://github.com/nextcloud/ios-communication-library",
+        "repositoryURL": "https://github.com/nextcloud/ios-communication-library/",
         "state": {
           "branch": null,
-          "revision": "e26939278c34dbe66a5a25963906651570b51fbe",
-          "version": "0.97.0"
+          "revision": "d07477d0cf9657512c29295fa5340420d82d85d3",
+          "version": "0.98.0"
         }
       },
       {
@@ -141,8 +141,8 @@
         "repositoryURL": "https://github.com/rechsteiner/Parchment",
         "state": {
           "branch": null,
-          "revision": "af4c9773ad7833df93b3f6226ccd78acad6f5735",
-          "version": "2.4.0"
+          "revision": "689ecaa80b7b0f712887ec87746f8598f2e12907",
+          "version": "3.0.1"
         }
       },
       {
@@ -177,8 +177,8 @@
         "repositoryURL": "https://github.com/realm/realm-cocoa",
         "state": {
           "branch": null,
-          "revision": "ae8e646590396dfc13c1abbf8aa2e48c43766dce",
-          "version": "10.7.2"
+          "revision": "7e5c77fd7fbb30259e8e6e6a41f32289f72e0812",
+          "version": "10.7.6"
         }
       },
       {
@@ -186,8 +186,8 @@
         "repositoryURL": "https://github.com/realm/realm-core",
         "state": {
           "branch": null,
-          "revision": "bab46acdca91c417a0d4849b8f4992a3c17e29a5",
-          "version": "10.5.5"
+          "revision": "018adb3469c2882904febca251778129ef4a9b70",
+          "version": "10.7.2"
         }
       },
       {

+ 1 - 1
Nextcloud.xcodeproj/xcshareddata/xcschemes/File Provider Extension.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "1240"
+   LastUpgradeVersion = "1250"
    wasCreatedForAppExtension = "YES"
    version = "2.0">
    <BuildAction

+ 1 - 1
Nextcloud.xcodeproj/xcshareddata/xcschemes/Nextcloud.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "1240"
+   LastUpgradeVersion = "1250"
    version = "1.7">
    <BuildAction
       parallelizeBuildables = "YES"

+ 8 - 4
Nextcloud.xcodeproj/xcshareddata/xcschemes/Share.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "1240"
+   LastUpgradeVersion = "1250"
    wasCreatedForAppExtension = "YES"
    version = "2.0">
    <BuildAction
@@ -66,8 +66,12 @@
       debugServiceExtension = "internal"
       allowLocationSimulation = "YES"
       launchAutomaticallySubstyle = "2">
-      <BuildableProductRunnable
-         runnableDebuggingMode = "0">
+      <RemoteRunnable
+         runnableDebuggingMode = "1"
+         BundleIdentifier = "it.twsweb.Nextcloud"
+         RemotePath = "/Users/marinofaggiana/Library/Developer/CoreSimulator/Devices/4DBB1715-4E24-4CE7-B67C-CA327B95130C/data/Containers/Bundle/Application/F427D7FF-1632-4BB9-ADEA-A094898BB6C7/Nextcloud.app">
+      </RemoteRunnable>
+      <MacroExpansion>
          <BuildableReference
             BuildableIdentifier = "primary"
             BlueprintIdentifier = "F77B0DEB1D118A16002130FE"
@@ -75,7 +79,7 @@
             BlueprintName = "Nextcloud"
             ReferencedContainer = "container:Nextcloud.xcodeproj">
          </BuildableReference>
-      </BuildableProductRunnable>
+      </MacroExpansion>
    </LaunchAction>
    <ProfileAction
       buildConfiguration = "Release"

+ 1 - 0
Notification Service Extension/NotificationService.swift

@@ -19,6 +19,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+import UIKit
 import UserNotifications
 
 class NotificationService: UNNotificationServiceExtension {

+ 0 - 38
Share/CCCellShareExt.h

@@ -1,38 +0,0 @@
-//
-//  CCCellShareExt.h
-//  Nextcloud iOS
-//
-//  Created by Marino Faggiana on 27/01/16.
-//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  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/UIKit.h>
-
-@interface CCCellShareExt : UITableViewCell
-
-@property(nonatomic, weak) IBOutlet UIImageView *fileImageView;
-@property(nonatomic, weak) IBOutlet UITextField *fileName;
-@property(nonatomic, weak) IBOutlet UILabel *info;
-
-//Last position of the scroll of the swipe
-@property (nonatomic, assign) CGFloat lastContentOffset;
-
-//Index path of the cell swipe gesture ocured
-@property (nonatomic, strong) NSIndexPath *indexPath;
-
-@end

+ 0 - 45
Share/CCCellShareExt.m

@@ -1,45 +0,0 @@
-//
-//  CCCellShareExt.m
-//  Nextcloud iOS
-//
-//  Created by Marino Faggiana on 29/07/15.
-//  Copyright (c) 2015 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  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 "CCCellShareExt.h"
-
-@implementation CCCellShareExt
-
-- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
-{
-    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
-    if (self) {
-    }
-    return self;
-}
-
-- (void)setSelected:(BOOL)selected animated:(BOOL)animated
-{
-    [super setSelected:selected animated:animated];
-}
-
-- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
-    _lastContentOffset = scrollView.contentOffset.x;
-}
-
-@end

+ 0 - 65
Share/CCCellShareExt.xib

@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
-    <device id="retina6_1" orientation="portrait" appearance="light"/>
-    <dependencies>
-        <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CustomCellFileAndDirectory"/>
-        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-        <tableViewCell contentMode="scaleToFill" selectionStyle="blue" indentationWidth="0.0" reuseIdentifier="ShareExtCell" rowHeight="80" id="2" customClass="CCCellShareExt">
-            <rect key="frame" x="0.0" y="0.0" width="597" height="80"/>
-            <autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
-            <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="2" id="sQq-jC-UEV">
-                <rect key="frame" x="0.0" y="0.0" width="597" height="80"/>
-                <autoresizingMask key="autoresizingMask"/>
-                <subviews>
-                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" translatesAutoresizingMaskIntoConstraints="NO" id="5">
-                        <rect key="frame" x="10" y="5" width="70" height="70"/>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="70" id="2Z3-9a-dWb"/>
-                            <constraint firstAttribute="width" constant="70" id="fbQ-SN-CAK"/>
-                        </constraints>
-                    </imageView>
-                    <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="VsB-d4-Sow">
-                        <rect key="frame" x="90" y="20" width="497" height="20"/>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="20" id="Dk0-na-bfK"/>
-                        </constraints>
-                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                        <textInputTraits key="textInputTraits"/>
-                    </textField>
-                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0Ow-Hb-LiN">
-                        <rect key="frame" x="90" y="55" width="497" height="20"/>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="20" id="9pk-f4-eS9"/>
-                        </constraints>
-                        <fontDescription key="fontDescription" type="system" pointSize="12"/>
-                        <nil key="textColor"/>
-                        <nil key="highlightedColor"/>
-                    </label>
-                </subviews>
-                <constraints>
-                    <constraint firstItem="5" firstAttribute="centerY" secondItem="sQq-jC-UEV" secondAttribute="centerY" id="3LF-0l-IUQ"/>
-                    <constraint firstItem="VsB-d4-Sow" firstAttribute="leading" secondItem="5" secondAttribute="trailing" constant="10" id="CrK-6o-Z32"/>
-                    <constraint firstAttribute="trailing" secondItem="0Ow-Hb-LiN" secondAttribute="trailing" constant="10" id="DiV-IR-cy6"/>
-                    <constraint firstAttribute="bottom" secondItem="0Ow-Hb-LiN" secondAttribute="bottom" constant="5" id="ObO-OF-tvn"/>
-                    <constraint firstItem="0Ow-Hb-LiN" firstAttribute="leading" secondItem="5" secondAttribute="trailing" constant="10" id="PFo-Au-ORj"/>
-                    <constraint firstAttribute="trailing" secondItem="VsB-d4-Sow" secondAttribute="trailing" constant="10" id="Q94-2Q-wue"/>
-                    <constraint firstItem="5" firstAttribute="leading" secondItem="sQq-jC-UEV" secondAttribute="leading" constant="10" id="fuA-E4-YoA"/>
-                    <constraint firstItem="VsB-d4-Sow" firstAttribute="top" secondItem="sQq-jC-UEV" secondAttribute="top" constant="20" id="pdW-jk-v6V"/>
-                </constraints>
-            </tableViewCellContentView>
-            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-            <connections>
-                <outlet property="Info" destination="9pk-f4-eS9" id="vm7-h8-kBz"/>
-                <outlet property="fileImageView" destination="5" id="6"/>
-                <outlet property="fileName" destination="VsB-d4-Sow" id="IiA-92-aJd"/>
-                <outlet property="info" destination="0Ow-Hb-LiN" id="Hhb-VE-mwc"/>
-            </connections>
-            <point key="canvasLocation" x="248.55072463768118" y="278.57142857142856"/>
-        </tableViewCell>
-    </objects>
-</document>

+ 0 - 205
Share/CCloadItemData.swift

@@ -1,205 +0,0 @@
-//
-//  CCloadItemData.swift
-//  Nextcloud iOS
-//
-//  Created by Marino Faggiana on 19/02/16.
-//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  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
-import MobileCoreServices
-
-class CCloadItemData: NSObject {
-    
-    @objc func loadFiles(_ directory: String, extensionContext: NSExtensionContext, vc: ShareViewController) {
-        
-        var filesName: [String] = []
-        var conuter = 0
-        
-        CCUtility.emptyTemporaryDirectory()
-                
-        if let inputItems : [NSExtensionItem] = extensionContext.inputItems as? [NSExtensionItem] {
-            
-            for item : NSExtensionItem in inputItems {
-                
-                if let attachments = item.attachments {
-                    
-                    if attachments.isEmpty {
-                        
-                        extensionContext.completeRequest(returningItems: nil, completionHandler: nil)
-                        
-                        vc.performSelector(onMainThread: #selector(vc.close), with: nil, waitUntilDone: false);
-                        
-                        return
-                    }
-                    
-                    for (index, current) in (attachments.enumerated()) {
-                        
-                        if current.hasItemConformingToTypeIdentifier(kUTTypeItem as String) || current.hasItemConformingToTypeIdentifier("public.url") {
-                            
-                            var typeIdentifier = ""
-                            if current.hasItemConformingToTypeIdentifier(kUTTypeItem as String) { typeIdentifier = kUTTypeItem as String }
-                            if current.hasItemConformingToTypeIdentifier("public.url") { typeIdentifier = "public.url" }
-                            
-                            current.loadItem(forTypeIdentifier: typeIdentifier, options: nil, completionHandler: {(item, error) -> Void in
-                                
-                                var fileNameOriginal: String?
-                                var fileName: String = ""
-                                
-                                let dateFormatter = DateFormatter()
-                                dateFormatter.dateFormat = "yyyy-MM-dd HH-mm-ss-"
-                                conuter += 1
-                                
-                                if let url = item as? NSURL {
-                                    fileNameOriginal = url.lastPathComponent!
-                                }
-                                
-                                if error == nil {
-                                                                        
-                                    if let image = item as? UIImage {
-                                        
-                                        print("item as UIImage")
-                                        
-                                        if let pngImageData = image.pngData() {
-                                        
-                                            if fileNameOriginal != nil {
-                                                fileName =  fileNameOriginal!
-                                            } else {
-                                                fileName = "\(dateFormatter.string(from: Date()))\(conuter).png"
-                                            }
-                                            
-                                            let filenamePath = directory + fileName
-                                            
-                                            let result = (try? pngImageData.write(to: URL(fileURLWithPath: filenamePath), options: [.atomic])) != nil
-                                        
-                                            if result {
-                                                filesName.append(fileName)
-                                            }
-                                            
-                                        } else {
-                                         
-                                            print("Error image nil")
-                                        }
-                                    }
-                                    
-                                    if let url = item as? URL {
-                                        
-                                        print("item as url: \(String(describing: item))")
-                                        
-                                        if fileNameOriginal != nil {
-                                            fileName =  fileNameOriginal!
-                                        } else {
-                                            let ext = url.pathExtension
-                                            fileName = "\(dateFormatter.string(from: Date()))\(conuter)." + ext
-                                        }
-                                        
-                                        let filenamePath = directory + fileName
-                                      
-                                        do {
-                                            try FileManager.default.removeItem(atPath: filenamePath)
-                                        }
-                                        catch let error as NSError {
-                                            print("Ooops! Something went wrong: \(error)")
-                                        }
-                                        
-                                        do {
-                                            try FileManager.default.copyItem(atPath: url.path, toPath:filenamePath)
-                                            
-                                            do {
-                                                let attr : NSDictionary? = try FileManager.default.attributesOfItem(atPath: filenamePath) as NSDictionary?
-                                                
-                                                if let _attr = attr {
-                                                    if _attr.fileSize() > 0 {
-                                                        
-                                                        filesName.append(fileName)
-                                                    }
-                                                }
-                                                
-                                            } catch let error as NSError {
-                                                
-                                                print("Error: \(error.localizedDescription)")
-                                            }                                            
-                                        } catch let error as NSError {
-                                            
-                                            print("Cannot copy file: \(error.localizedDescription)")
-                                        }
-                                    }
-                                    
-                                    if let data = item as? Data {
-                                        
-                                        if data.count > 0 {
-                                        
-                                            print("item as NSdata")
-                                        
-                                            if fileNameOriginal != nil {
-                                                fileName =  fileNameOriginal!
-                                            } else {
-                                                let description = current.description
-                                                let fullNameArr = description.components(separatedBy: "\"")
-                                                let fileExtArr = fullNameArr[1].components(separatedBy: ".")
-                                                let pathExtention = (fileExtArr[fileExtArr.count-1]).uppercased()
-                                                fileName = "\(dateFormatter.string(from: Date()))\(conuter).\(pathExtention)"
-                                            }
-                                            
-                                            let filenamePath = directory + fileName
-                                            
-                                            FileManager.default.createFile(atPath: filenamePath, contents:data, attributes:nil)
-                                                                                
-                                            filesName.append(fileName)
-                                        }
-                                    }
-                                    
-                                    if let data = item as? NSString {
-                                        
-                                        if data.length > 0 {
-                                        
-                                            print("item as NSString")
-                                        
-                                            let fileName = "\(dateFormatter.string(from: Date()))\(conuter).txt"
-                                            let filenamePath = directory + fileName
-                                        
-                                            FileManager.default.createFile(atPath: filenamePath, contents:data.data(using: String.Encoding.utf8.rawValue), attributes:nil)
-                                        
-                                            filesName.append(fileName)
-                                        }
-                                    }
-                                    
-                                    if index + 1 == attachments.count {
-                                        
-                                        vc.performSelector(onMainThread: #selector(vc.reloadData), with:filesName, waitUntilDone: false)
-                                    }
-                                    
-                                }
-                            })
-                            
-                        }
-                        
-                    } // end for
-
-                } else {
-                    
-                    vc.performSelector(onMainThread: #selector(vc.close), with: nil, waitUntilDone: false);
-                }
-            }
-            
-        } else {
-            
-            vc.performSelector(onMainThread: #selector(vc.close), with: nil, waitUntilDone: false);
-        }
-    }
-}

+ 216 - 68
Share/MainInterface.storyboard

@@ -1,90 +1,238 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="yQd-yC-53O">
-    <device id="retina4_7" orientation="portrait" appearance="light"/>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="EAU-PF-EEd">
+    <device id="retina6_5" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
+        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
-        <!--Navigation Controller-->
-        <scene sceneID="ueh-Ta-TQZ">
+        <!--Share Extension-->
+        <scene sceneID="d4X-6u-1HM">
             <objects>
-                <navigationController id="yQd-yC-53O" sceneMemberID="viewController">
-                    <nil key="simulatedStatusBarMetrics"/>
-                    <navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="Qr0-yX-mDZ">
-                        <rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
-                        <autoresizingMask key="autoresizingMask"/>
-                    </navigationBar>
-                    <connections>
-                        <segue destination="j1y-V4-xli" kind="relationship" relationship="rootViewController" id="dCI-hj-EK1"/>
-                    </connections>
-                </navigationController>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="SCm-q2-twq" userLabel="First Responder" sceneMemberID="firstResponder"/>
-            </objects>
-            <point key="canvasLocation" x="-1057" y="-210"/>
-        </scene>
-        <!--Share View Controller-->
-        <scene sceneID="ceB-am-kn3">
-            <objects>
-                <viewController id="j1y-V4-xli" customClass="ShareViewController" sceneMemberID="viewController">
-                    <layoutGuides>
-                        <viewControllerLayoutGuide type="top" id="8bI-gs-bmD"/>
-                        <viewControllerLayoutGuide type="bottom" id="d5i-Ba-RvD"/>
-                    </layoutGuides>
-                    <view key="view" contentMode="scaleToFill" id="wbc-yd-nQP">
-                        <rect key="frame" x="0.0" y="0.0" width="375" height="623"/>
+                <viewController storyboardIdentifier="NCShareExtension.storyboard" id="VYq-xA-D35" customClass="NCShareExtension" customModule="Share" customModuleProvider="target" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="MaM-Im-7sc">
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <toolbar contentMode="scaleToFill" translucent="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gad-k1-Oh8">
-                                <rect key="frame" x="-8" y="579" width="387" height="44"/>
-                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                                <constraints>
-                                    <constraint firstAttribute="height" constant="44" id="rZR-ep-syc"/>
-                                </constraints>
-                                <items>
-                                    <barButtonItem style="plain" systemItem="flexibleSpace" id="ski-H2-N9g"/>
-                                    <barButtonItem title="Item" id="Dpo-t5-Knx">
-                                        <connections>
-                                            <action selector="destinyFolderButtonTapped:" destination="j1y-V4-xli" id="vt9-MN-l6i"/>
-                                        </connections>
-                                    </barButtonItem>
-                                    <barButtonItem style="plain" systemItem="flexibleSpace" id="eZh-WQ-5L1"/>
-                                </items>
-                            </toolbar>
-                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="110" sectionHeaderHeight="1" sectionFooterHeight="1" translatesAutoresizingMaskIntoConstraints="NO" id="6bg-ed-mfL">
-                                <rect key="frame" x="0.0" y="0.0" width="375" height="579"/>
-                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="0HI-k1-SD0">
+                                <rect key="frame" x="0.0" y="88" width="414" height="418"/>
+                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="D7P-75-aB1">
+                                    <size key="itemSize" width="0.0" height="0.0"/>
+                                    <size key="headerReferenceSize" width="0.0" height="0.0"/>
+                                    <size key="footerReferenceSize" width="0.0" height="0.0"/>
+                                    <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
+                                </collectionViewFlowLayout>
+                                <cells/>
                                 <connections>
-                                    <outlet property="dataSource" destination="j1y-V4-xli" id="cqC-oT-nbV"/>
-                                    <outlet property="delegate" destination="j1y-V4-xli" id="WE4-Xb-ohZ"/>
+                                    <outlet property="dataSource" destination="VYq-xA-D35" id="knG-ac-buS"/>
+                                    <outlet property="delegate" destination="VYq-xA-D35" id="EXB-bA-tje"/>
                                 </connections>
-                            </tableView>
+                            </collectionView>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FaV-kz-PEs">
+                                <rect key="frame" x="0.0" y="506" width="414" height="390"/>
+                                <subviews>
+                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LAs-iQ-u1X">
+                                        <rect key="frame" x="0.0" y="0.0" width="414" height="1"/>
+                                        <color key="backgroundColor" systemColor="separatorColor"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="1" id="wOp-so-23c"/>
+                                        </constraints>
+                                    </view>
+                                    <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="eU0-LW-AnG">
+                                        <rect key="frame" x="10" y="70" width="394" height="220"/>
+                                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                        <prototypes>
+                                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="Cell" rowHeight="50" id="6Kt-n0-i8J">
+                                                <rect key="frame" x="0.0" y="28" width="394" height="50"/>
+                                                <autoresizingMask key="autoresizingMask"/>
+                                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="6Kt-n0-i8J" id="WGN-Zn-lR8">
+                                                    <rect key="frame" x="0.0" y="0.0" width="394" height="50"/>
+                                                    <autoresizingMask key="autoresizingMask"/>
+                                                    <subviews>
+                                                        <imageView clipsSubviews="YES" userInteractionEnabled="NO" tag="10" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="uvl-De-S9p">
+                                                            <rect key="frame" x="10" y="5" width="40" height="40"/>
+                                                            <constraints>
+                                                                <constraint firstAttribute="width" constant="40" id="Vpb-6e-ta9"/>
+                                                                <constraint firstAttribute="height" constant="40" id="wvf-Ey-woY"/>
+                                                            </constraints>
+                                                        </imageView>
+                                                        <label opaque="NO" userInteractionEnabled="NO" tag="20" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rz6-pe-DB5">
+                                                            <rect key="frame" x="60" y="16.666666666666668" width="284" height="17.000000000000004"/>
+                                                            <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                            <nil key="textColor"/>
+                                                            <nil key="highlightedColor"/>
+                                                        </label>
+                                                        <button opaque="NO" tag="30" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OGY-95-ZYi" customClass="NCShareExtensionButtonWithIndexPath" customModule="Share" customModuleProvider="target">
+                                                            <rect key="frame" x="354" y="10" width="30" height="30"/>
+                                                            <constraints>
+                                                                <constraint firstAttribute="height" constant="30" id="QqR-Uw-RnV"/>
+                                                                <constraint firstAttribute="width" constant="30" id="bpm-t5-3HA"/>
+                                                            </constraints>
+                                                            <state key="normal" image="pencil"/>
+                                                        </button>
+                                                    </subviews>
+                                                    <constraints>
+                                                        <constraint firstItem="rz6-pe-DB5" firstAttribute="centerY" secondItem="WGN-Zn-lR8" secondAttribute="centerY" id="Ag7-Ow-Ifk"/>
+                                                        <constraint firstItem="OGY-95-ZYi" firstAttribute="centerY" secondItem="WGN-Zn-lR8" secondAttribute="centerY" id="Mgu-E2-kgA"/>
+                                                        <constraint firstItem="uvl-De-S9p" firstAttribute="centerY" secondItem="WGN-Zn-lR8" secondAttribute="centerY" id="bFC-cS-ePy"/>
+                                                        <constraint firstItem="rz6-pe-DB5" firstAttribute="leading" secondItem="uvl-De-S9p" secondAttribute="trailing" constant="10" id="f94-aJ-igq"/>
+                                                        <constraint firstItem="uvl-De-S9p" firstAttribute="leading" secondItem="WGN-Zn-lR8" secondAttribute="leading" constant="10" id="ko0-iM-oWa"/>
+                                                        <constraint firstAttribute="trailing" secondItem="OGY-95-ZYi" secondAttribute="trailing" constant="10" id="si1-LI-Ldn"/>
+                                                        <constraint firstItem="OGY-95-ZYi" firstAttribute="leading" secondItem="rz6-pe-DB5" secondAttribute="trailing" constant="10" id="vCb-2c-vWa"/>
+                                                    </constraints>
+                                                </tableViewCellContentView>
+                                                <inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
+                                            </tableViewCell>
+                                        </prototypes>
+                                        <connections>
+                                            <outlet property="dataSource" destination="VYq-xA-D35" id="pzA-Br-UUG"/>
+                                            <outlet property="delegate" destination="VYq-xA-D35" id="DAj-hF-SRY"/>
+                                        </connections>
+                                    </tableView>
+                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Tbe-Jp-I8U">
+                                        <rect key="frame" x="10" y="10" width="394" height="50"/>
+                                        <subviews>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="create folder" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WHW-J5-8gq">
+                                                <rect key="frame" x="59.999999999999993" y="16.666666666666629" width="82.333333333333314" height="17"/>
+                                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                <nil key="textColor"/>
+                                                <nil key="highlightedColor"/>
+                                            </label>
+                                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="R3X-g5-ZFs">
+                                                <rect key="frame" x="15" y="10" width="30" height="30"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="width" constant="30" id="9Qc-Ji-5yh"/>
+                                                    <constraint firstAttribute="height" constant="30" id="UUM-06-R5m"/>
+                                                </constraints>
+                                            </imageView>
+                                        </subviews>
+                                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="50" id="Py5-lr-dJD"/>
+                                            <constraint firstItem="WHW-J5-8gq" firstAttribute="centerY" secondItem="Tbe-Jp-I8U" secondAttribute="centerY" id="ccx-II-bpQ"/>
+                                            <constraint firstItem="WHW-J5-8gq" firstAttribute="leading" secondItem="R3X-g5-ZFs" secondAttribute="trailing" constant="15" id="iOH-BT-dux"/>
+                                            <constraint firstItem="R3X-g5-ZFs" firstAttribute="centerY" secondItem="Tbe-Jp-I8U" secondAttribute="centerY" id="mJt-qE-buH"/>
+                                            <constraint firstItem="R3X-g5-ZFs" firstAttribute="leading" secondItem="Tbe-Jp-I8U" secondAttribute="leading" constant="15" id="qgl-VD-5v8"/>
+                                        </constraints>
+                                    </view>
+                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kHU-CI-3gI">
+                                        <rect key="frame" x="10" y="300" width="394" height="50"/>
+                                        <subviews>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="upload" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ka7-SC-ac5">
+                                                <rect key="frame" x="171" y="14.999999999999998" width="52" height="20.333333333333329"/>
+                                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                <nil key="textColor"/>
+                                                <nil key="highlightedColor"/>
+                                            </label>
+                                            <imageView hidden="YES" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Gok-do-ydQ">
+                                                <rect key="frame" x="15" y="10" width="30" height="30"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="height" constant="30" id="hof-u1-w4Q"/>
+                                                    <constraint firstAttribute="width" constant="30" id="n6T-Di-HBC"/>
+                                                </constraints>
+                                            </imageView>
+                                        </subviews>
+                                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                        <constraints>
+                                            <constraint firstItem="ka7-SC-ac5" firstAttribute="centerX" secondItem="kHU-CI-3gI" secondAttribute="centerX" id="0xa-aH-g8H"/>
+                                            <constraint firstItem="Gok-do-ydQ" firstAttribute="leading" secondItem="kHU-CI-3gI" secondAttribute="leading" constant="15" id="3bo-Wd-s5E"/>
+                                            <constraint firstAttribute="height" constant="50" id="6xq-PW-8Ay"/>
+                                            <constraint firstItem="Gok-do-ydQ" firstAttribute="centerY" secondItem="kHU-CI-3gI" secondAttribute="centerY" id="P9O-Ts-odZ"/>
+                                            <constraint firstItem="ka7-SC-ac5" firstAttribute="centerY" secondItem="kHU-CI-3gI" secondAttribute="centerY" id="u7t-cL-zFA"/>
+                                        </constraints>
+                                    </view>
+                                </subviews>
+                                <color key="backgroundColor" systemColor="systemGray6Color"/>
+                                <constraints>
+                                    <constraint firstItem="Tbe-Jp-I8U" firstAttribute="top" secondItem="FaV-kz-PEs" secondAttribute="top" constant="10" id="4im-Bh-Rf7"/>
+                                    <constraint firstAttribute="height" constant="390" id="50u-lA-AUo"/>
+                                    <constraint firstAttribute="trailing" secondItem="kHU-CI-3gI" secondAttribute="trailing" constant="10" id="8id-Gf-ki5"/>
+                                    <constraint firstAttribute="trailing" secondItem="Tbe-Jp-I8U" secondAttribute="trailing" constant="10" id="9O7-wg-OlH"/>
+                                    <constraint firstItem="eU0-LW-AnG" firstAttribute="leading" secondItem="FaV-kz-PEs" secondAttribute="leading" constant="10" id="E40-Ul-MEV"/>
+                                    <constraint firstItem="eU0-LW-AnG" firstAttribute="top" secondItem="Tbe-Jp-I8U" secondAttribute="bottom" constant="10" id="Iwl-0n-oDz"/>
+                                    <constraint firstItem="LAs-iQ-u1X" firstAttribute="leading" secondItem="FaV-kz-PEs" secondAttribute="leading" id="dr0-zN-pwa"/>
+                                    <constraint firstItem="kHU-CI-3gI" firstAttribute="leading" secondItem="FaV-kz-PEs" secondAttribute="leading" constant="10" id="dtw-q4-l5s"/>
+                                    <constraint firstItem="kHU-CI-3gI" firstAttribute="top" secondItem="eU0-LW-AnG" secondAttribute="bottom" constant="10" id="ecC-SY-AEU"/>
+                                    <constraint firstItem="LAs-iQ-u1X" firstAttribute="top" secondItem="FaV-kz-PEs" secondAttribute="top" id="gvj-gm-XbO"/>
+                                    <constraint firstItem="Tbe-Jp-I8U" firstAttribute="leading" secondItem="FaV-kz-PEs" secondAttribute="leading" constant="10" id="nB1-9c-DmY"/>
+                                    <constraint firstAttribute="trailing" secondItem="eU0-LW-AnG" secondAttribute="trailing" constant="10" id="qQA-Ix-Ge1"/>
+                                    <constraint firstAttribute="bottom" secondItem="eU0-LW-AnG" secondAttribute="bottom" constant="100" id="r6E-QV-nj7"/>
+                                    <constraint firstAttribute="trailing" secondItem="LAs-iQ-u1X" secondAttribute="trailing" id="v8j-JB-2Io"/>
+                                </constraints>
+                            </view>
                         </subviews>
-                        <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <viewLayoutGuide key="safeArea" id="vaA-85-uNN"/>
+                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                         <constraints>
-                            <constraint firstAttribute="trailingMargin" secondItem="gad-k1-Oh8" secondAttribute="trailing" constant="-20" id="Ogc-Ss-sTA"/>
-                            <constraint firstAttribute="trailing" secondItem="6bg-ed-mfL" secondAttribute="trailing" id="dku-zI-tdG"/>
-                            <constraint firstItem="d5i-Ba-RvD" firstAttribute="top" secondItem="gad-k1-Oh8" secondAttribute="bottom" id="n1F-h4-Uxd"/>
-                            <constraint firstItem="gad-k1-Oh8" firstAttribute="top" secondItem="6bg-ed-mfL" secondAttribute="bottom" id="qEs-cg-DMH"/>
-                            <constraint firstItem="gad-k1-Oh8" firstAttribute="leadingMargin" secondItem="wbc-yd-nQP" secondAttribute="leadingMargin" constant="-16" id="qnK-zI-jNY"/>
-                            <constraint firstItem="6bg-ed-mfL" firstAttribute="top" secondItem="8bI-gs-bmD" secondAttribute="bottom" id="sKS-dx-tS9"/>
-                            <constraint firstItem="gad-k1-Oh8" firstAttribute="top" secondItem="6bg-ed-mfL" secondAttribute="bottom" id="xUM-bt-esX"/>
-                            <constraint firstItem="6bg-ed-mfL" firstAttribute="leading" secondItem="wbc-yd-nQP" secondAttribute="leading" id="xkR-sP-qEX"/>
+                            <constraint firstItem="0HI-k1-SD0" firstAttribute="top" secondItem="vaA-85-uNN" secondAttribute="top" id="552-sP-Paj"/>
+                            <constraint firstAttribute="bottom" secondItem="FaV-kz-PEs" secondAttribute="bottom" id="7TV-nN-N7u"/>
+                            <constraint firstItem="FaV-kz-PEs" firstAttribute="leading" secondItem="vaA-85-uNN" secondAttribute="leading" id="DUP-nF-RRO"/>
+                            <constraint firstItem="vaA-85-uNN" firstAttribute="trailing" secondItem="FaV-kz-PEs" secondAttribute="trailing" id="GSd-jh-TJN"/>
+                            <constraint firstItem="vaA-85-uNN" firstAttribute="trailing" secondItem="0HI-k1-SD0" secondAttribute="trailing" id="KT1-YT-Lps"/>
+                            <constraint firstItem="FaV-kz-PEs" firstAttribute="top" secondItem="0HI-k1-SD0" secondAttribute="bottom" id="sQc-Jm-MaY"/>
+                            <constraint firstItem="0HI-k1-SD0" firstAttribute="leading" secondItem="vaA-85-uNN" secondAttribute="leading" id="uLL-RT-YFO"/>
                         </constraints>
                     </view>
-                    <navigationItem key="navigationItem" id="DwO-O2-rAX"/>
-                    <nil key="simulatedStatusBarMetrics"/>
+                    <navigationItem key="navigationItem" id="N5K-De-4CP">
+                        <barButtonItem key="rightBarButtonItem" title="cancel" id="qHj-AF-EN7">
+                            <connections>
+                                <action selector="actionCancel:" destination="VYq-xA-D35" id="LRW-H2-pbh"/>
+                            </connections>
+                        </barButtonItem>
+                    </navigationItem>
                     <connections>
-                        <outlet property="constraintTopTableView" destination="sKS-dx-tS9" id="Cps-IG-Eih"/>
-                        <outlet property="destinyFolderButton" destination="Dpo-t5-Knx" id="9p8-c0-Ocm"/>
-                        <outlet property="shareTable" destination="6bg-ed-mfL" id="tzz-SO-m9D"/>
-                        <outlet property="toolBar" destination="gad-k1-Oh8" id="gAK-GL-EcZ"/>
+                        <outlet property="cancelButton" destination="qHj-AF-EN7" id="ArV-Vj-BiO"/>
+                        <outlet property="collectionView" destination="0HI-k1-SD0" id="xme-mG-bnz"/>
+                        <outlet property="commandView" destination="FaV-kz-PEs" id="s91-n4-PKE"/>
+                        <outlet property="commandViewHeightConstraint" destination="50u-lA-AUo" id="ygm-ah-cHw"/>
+                        <outlet property="createFolderImage" destination="R3X-g5-ZFs" id="klm-3T-tiU"/>
+                        <outlet property="createFolderLabel" destination="WHW-J5-8gq" id="N93-Bs-sc9"/>
+                        <outlet property="createFolderView" destination="Tbe-Jp-I8U" id="W59-Hm-lCw"/>
+                        <outlet property="separatorHeightConstraint" destination="wOp-so-23c" id="r8x-LQ-sxb"/>
+                        <outlet property="separatorView" destination="LAs-iQ-u1X" id="53E-lW-30T"/>
+                        <outlet property="tableView" destination="eU0-LW-AnG" id="mLD-VN-uyz"/>
+                        <outlet property="uploadImage" destination="Gok-do-ydQ" id="lZa-JZ-LCk"/>
+                        <outlet property="uploadLabel" destination="ka7-SC-ac5" id="yTg-qK-MjJ"/>
+                        <outlet property="uploadView" destination="kHU-CI-3gI" id="Iok-Qb-nGR"/>
                     </connections>
                 </viewController>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="CEy-Cv-SGf" userLabel="First Responder" sceneMemberID="firstResponder"/>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="vH8-UY-9MN" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="1195.6521739130435" y="227.67857142857142"/>
+        </scene>
+        <!--Navigation Controller-->
+        <scene sceneID="KP9-Ja-zsS">
+            <objects>
+                <navigationController automaticallyAdjustsScrollViewInsets="NO" id="EAU-PF-EEd" sceneMemberID="viewController">
+                    <toolbarItems/>
+                    <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="OMR-Ah-U1w">
+                        <rect key="frame" x="0.0" y="44" width="414" height="44"/>
+                        <autoresizingMask key="autoresizingMask"/>
+                    </navigationBar>
+                    <nil name="viewControllers"/>
+                    <connections>
+                        <segue destination="VYq-xA-D35" kind="relationship" relationship="rootViewController" id="dZh-kL-x5f"/>
+                    </connections>
+                </navigationController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="rcK-ZU-zTS" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="-290" y="-210"/>
+            <point key="canvasLocation" x="256.80000000000001" y="228.93553223388307"/>
         </scene>
     </scenes>
+    <resources>
+        <image name="pencil" width="16" height="16"/>
+        <systemColor name="separatorColor">
+            <color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
+        <systemColor name="systemBackgroundColor">
+            <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
+        <systemColor name="systemGray6Color">
+            <color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
+    </resources>
 </document>

+ 0 - 65
Share/NCSelectDestination.h

@@ -1,65 +0,0 @@
-//
-//  NCSelectDestination.h
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 04/09/14.
-//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  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/UIKit.h>
-
-#import "CCUtility.h"
-
-@class tableMetadata;
-
-@protocol NCSelectDestinationDelegate;
-
-@interface NCSelectDestination : UITableViewController <UIAlertViewDelegate, UITableViewDelegate>
-
-@property (nonatomic, weak) id <NCSelectDestinationDelegate> delegate;
-
-@property BOOL includeDirectoryE2EEncryption;
-@property BOOL includeImages;
-
-@property BOOL hideCreateFolder;
-@property BOOL hideMoveutton;
-
-@property BOOL selectFile;
-
-@property (nonatomic, strong) NSString *serverUrl;
-@property (nonatomic, strong) tableMetadata *passMetadata;
-@property (nonatomic, strong) NSString *type;
-
-// Color
-@property (nonatomic, strong) UIColor *barTintColor;
-@property (nonatomic, strong) UIColor *tintColor;
-@property (nonatomic, strong) UIColor *tintColorTitle;
-
-@property (nonatomic, weak) IBOutlet UIBarButtonItem *cancel;
-@property (nonatomic, weak) IBOutlet UIBarButtonItem *move;
-@property (nonatomic, weak) IBOutlet UIBarButtonItem *create;
-
-@end
-
-@protocol NCSelectDestinationDelegate <NSObject>
-
-@optional - (void)moveServerUrlTo:(NSString *)serverUrlTo title:(NSString *)title type:(NSString *)type;
-@optional - (void)dismissMove;
-@optional - (void)selectMetadata:(tableMetadata *)metadata serverUrl:(NSString *)serverUrl;
-
-@end

+ 0 - 320
Share/NCSelectDestination.m

@@ -1,320 +0,0 @@
-//
-//  CCMove.m
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 04/09/14.
-//  Copyright (c) 2014 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  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 "NCSelectDestination.h"
-#import "NCBridgeSwift.h"
-
-@interface NCSelectDestination ()
-{    
-    NSString *account;
-    NSString *urlBase;
-  
-    BOOL _loadingFolder;
-    
-    // Automatic Upload Folder
-    NSString *_autoUploadFileName;
-    NSString *_autoUploadDirectory;
-    
-    NSPredicate *predicateDataSource;
-}
-@end
-
-@implementation NCSelectDestination
-
-// MARK: - View
-
-- (void)viewDidLoad
-{
-    [super viewDidLoad];
-    
-    tableAccount *tableAccount = [[NCManageDatabase shared] getAccountActive];
-    
-    if (tableAccount) {
-        
-        account = tableAccount.account;
-        urlBase = tableAccount.urlBase;
-                
-    } else {
-        
-        UIAlertController * alert= [UIAlertController alertControllerWithTitle:nil message:NSLocalizedString(@"_no_active_account_", nil) preferredStyle:UIAlertControllerStyleAlert];
-        UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
-            [alert dismissViewControllerAnimated:YES completion:nil];
-        }];
-        [alert addAction:ok];
-        [self presentViewController:alert animated:YES completion:nil];
-    }
-    
-    [self.cancel setTitle:NSLocalizedString(@"_cancel_", nil)];
-    [self.create setTitle:NSLocalizedString(@"_create_folder_", nil)];
-    
-    UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0,0, self.navigationItem.titleView.frame.size.width, 40)];
-    label.textColor = NCBrandColor.shared.brandText;
-    label.backgroundColor =[UIColor clearColor];
-    label.textAlignment = NSTextAlignmentCenter;
-    
-    if (![_serverUrl length]) {
-                
-        _serverUrl = [[NCUtilityFileSystem shared] getHomeServerWithUrlBase:urlBase account:account];
-        label.text = NSLocalizedString(@"_home_dir_", nil);
-        
-    } else {
-               
-        label.text = self.passMetadata.fileNameView;
-    }
-    
-    self.navigationItem.titleView = label;
-    
-    // TableView : at the end of rows nothing
-    self.tableView.tableFooterView = [UIView new];
-    self.tableView.separatorColor =  NCBrandColor.shared.separator;
-
-    // get auto upload folder
-    _autoUploadFileName = [[NCManageDatabase shared] getAccountAutoUploadFileName];
-    _autoUploadDirectory = [[NCManageDatabase shared] getAccountAutoUploadDirectoryWithUrlBase:urlBase account:account];
-    
-    [self readFolder];
-}
-
-// Apparirà
-- (void)viewWillAppear:(BOOL)animated
-{
-    [super viewWillAppear:animated];
-    
-    self.navigationController.navigationBar.barTintColor = NCBrandColor.shared.brandElement;
-    self.navigationController.navigationBar.tintColor = NCBrandColor.shared.brandText;
-    
-    self.navigationController.toolbar.barTintColor = NCBrandColor.shared.tabBar;
-    self.navigationController.toolbar.tintColor = [UIColor grayColor];
-    
-    if (self.hideCreateFolder) {
-        [self.create setEnabled:NO];
-        [self.create setTintColor: [UIColor clearColor]];
-    }
-    
-    if (self.hideMoveutton) {
-        [self.move setEnabled:NO];
-        [self.move setTintColor: [UIColor clearColor]];
-    }
-    
-    self.view.backgroundColor = NCBrandColor.shared.backgroundView;
-    self.tableView.backgroundColor = NCBrandColor.shared.backgroundView;
-}
-
-// MARK: - IBAction
-
-- (IBAction)cancel:(UIBarButtonItem *)sender
-{
-    if ([self.delegate respondsToSelector:@selector(dismissMove)])
-        [self.delegate dismissMove];
-    
-    [self dismissViewControllerAnimated:YES completion:nil];
-}
-
-- (IBAction)move:(UIBarButtonItem *)sender
-{
-    if ([self.delegate respondsToSelector:@selector(dismissMove)])
-        [self.delegate dismissMove];
-    
-    [self.delegate moveServerUrlTo:_serverUrl title:self.passMetadata.fileNameView type:self.type];
-        
-    [self dismissViewControllerAnimated:YES completion:nil];
-}
-
-- (IBAction)create:(UIBarButtonItem *)sender
-{
-    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_create_folder_",nil) message:@"" preferredStyle:UIAlertControllerStyleAlert];
-    
-    [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
-        //textField.placeholder = NSLocalizedString(@"LoginPlaceholder", @"Login");
-        textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
-    }];
-    
-    [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_save_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-        [self createFolder:alertController.textFields.firstObject.text];
-    }]];
-    
-    [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
-    }]];
-    
-    [self presentViewController:alertController animated:YES completion:nil];
-}
-
-// MARK: - Read Folder
-
-- (void)readFolder
-{
-    [[NCNetworking shared] readFolderWithServerUrl:_serverUrl account:account completion:^(NSString *account, tableMetadata *metadataFolder, NSArray *metadatas, NSArray *metadatasUpdate, NSArray *metadatasLocalUpdate, NSInteger errorCode, NSString *errorDescription) {
-        
-        if (errorCode == 0) {
-            self.move.enabled = true;
-        } else {
-            self.move.enabled = false;
-        }
-        
-        _loadingFolder = NO;
-        [self.tableView reloadData];
-    }];
-    
-    _loadingFolder = YES;
-    [self.tableView reloadData];
-}
-
-    
-// MARK: - Create Folder
-
-- (void)createFolder:(NSString *)fileNameFolder
-{
-    NSString *serverUrlFileName = [NSString stringWithFormat:@"%@/%@", _serverUrl, fileNameFolder];
-     
-    [[NCCommunication shared] createFolder:serverUrlFileName customUserAgent:nil addCustomHeaders:nil completionHandler:^(NSString *account, NSString *ocID, NSDate *date, NSInteger errorCode, NSString *errorDecription) {
-        if (errorCode == 0) {
-           [self readFolder];
-        } else {
-            UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_",nil) message:errorDecription preferredStyle:UIAlertControllerStyleAlert];
-            [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { }]];
-            [self presentViewController:alertController animated:YES completion:nil];
-        }
-    }];
-}
-
-// MARK: - Table
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
-{
-    return 1;
-}
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
-{
-    if (self.includeDirectoryE2EEncryption) {
-        
-        if (self.includeImages) {
-            predicateDataSource = [NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND (directory == true OR typeFile == 'image')", account, _serverUrl];
-        } else {
-            predicateDataSource = [NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND directory == true", account, _serverUrl];
-        }
-        
-    } else {
-        
-        if (self.includeImages) {
-            predicateDataSource = [NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND e2eEncrypted == false AND (directory == true OR typeFile == 'image')", account, _serverUrl];
-        } else {
-            predicateDataSource = [NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND e2eEncrypted == false AND directory == true", account, _serverUrl];
-        }
-    }
-    
-    NSArray *result = [[NCManageDatabase shared] getMetadatasWithPredicate:predicateDataSource];
-    
-    if (result)
-        return [result count];
-    else
-        return 0;    
-}
-
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
-{
-    static NSString *CellIdentifier = @"MyCustomCell";
-    
-    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
-    if (cell == nil) {
-        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
-    }
-    
-    tableMetadata *metadata = [[NCManageDatabase shared] getMetadataAtIndexWithPredicate:predicateDataSource sorted:@"fileName" ascending:YES index:indexPath.row];
-    
-    // Create Directory Provider Storage ocId
-    [CCUtility getDirectoryProviderStorageOcId:metadata.ocId];
-    
-    // colors
-    cell.textLabel.textColor = NCBrandColor.shared.textView;
-    
-    cell.detailTextLabel.text = @"";
-    
-    if (metadata.directory) {
-    
-        if (metadata.e2eEncrypted)
-            cell.imageView.image = [[UIImage imageNamed:@"folderEncrypted"] imageWithColor:NCBrandColor.shared.brandElement size:50];
-        else if ([metadata.fileName isEqualToString:_autoUploadFileName] && [self.serverUrl isEqualToString:_autoUploadDirectory])
-            cell.imageView.image = [[UIImage imageNamed:@"folderAutomaticUpload"] imageWithColor:NCBrandColor.shared.brandElement size:50];
-        else
-            cell.imageView.image = [[UIImage imageNamed:@"folder"] imageWithColor:NCBrandColor.shared.brandElement size:50];
-        
-    } else {
-        
-        UIImage *thumb = [UIImage imageWithContentsOfFile:[CCUtility getDirectoryProviderStorageIconOcId:metadata.ocId etag:metadata.etag]];
-        
-        if (thumb) {
-            cell.imageView.image = thumb;
-        } else {
-            if (metadata.iconName.length > 0) {
-                cell.imageView.image = [UIImage imageNamed:metadata.iconName];
-            } else {
-                cell.imageView.image = [UIImage imageNamed:@"file"];
-            }
-        }
-    }
-
-    cell.textLabel.text = metadata.fileNameView;
-    cell.accessoryType = UITableViewCellAccessoryNone;
-    
-    return cell;
-}
-
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
-{
-    tableMetadata *metadata = [[NCManageDatabase shared] getMetadataAtIndexWithPredicate:predicateDataSource sorted:@"fileName" ascending:YES index:indexPath.row ];
-    
-    if (metadata.directory) {
-        
-        UINavigationController* navigationController = [[UIStoryboard storyboardWithName:@"NCSelectDestination" bundle:nil] instantiateInitialViewController];
-        NCSelectDestination *viewController = (NCSelectDestination *)navigationController.topViewController;
-        
-        viewController.delegate = self.delegate;
-        viewController.includeDirectoryE2EEncryption = self.includeDirectoryE2EEncryption;
-        viewController.includeImages = self.includeImages;
-        viewController.move.title = self.move.title;
-        viewController.hideCreateFolder = self.hideCreateFolder;
-        viewController.hideMoveutton = self.hideMoveutton;
-        viewController.selectFile = self.selectFile;
-        viewController.type = self.type;
-        viewController.passMetadata = metadata;
-        viewController.serverUrl = [CCUtility stringAppendServerUrl:_serverUrl addFileName:metadata.fileName];
-        
-        [self.navigationController pushViewController:viewController animated:YES];
-        
-    } else {
-        
-        if (self.selectFile) {
-            
-            if ([self.delegate respondsToSelector:@selector(dismissMove)])
-                [self.delegate dismissMove];
-            
-            if ([self.delegate respondsToSelector:@selector(selectMetadata:serverUrl:)])
-                [self.delegate selectMetadata:metadata serverUrl:_serverUrl];
-            
-            [self dismissViewControllerAnimated:YES completion:nil];
-        }
-    }
-}
-
-@end

+ 0 - 100
Share/NCSelectDestination.storyboard

@@ -1,100 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="GGi-ld-Icm">
-    <device id="retina4_7" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
-    <dependencies>
-        <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <scenes>
-        <!--Select Destination-->
-        <scene sceneID="72G-64-9xM">
-            <objects>
-                <tableViewController storyboardIdentifier="CCMoveVC" id="r57-Y0-NGA" customClass="NCSelectDestination" sceneMemberID="viewController">
-                    <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="50" sectionHeaderHeight="22" sectionFooterHeight="22" id="McT-Wl-5yC">
-                        <rect key="frame" x="0.0" y="0.0" width="375" height="559"/>
-                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                        <prototypes>
-                            <tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="MyCustomCell" textLabel="Z3y-WW-606" rowHeight="60" style="IBUITableViewCellStyleDefault" id="w3K-MH-HTI">
-                                <rect key="frame" x="0.0" y="22" width="375" height="60"/>
-                                <autoresizingMask key="autoresizingMask"/>
-                                <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="w3K-MH-HTI" id="o7i-Tv-3Dy">
-                                    <rect key="frame" x="0.0" y="0.0" width="341" height="59.5"/>
-                                    <autoresizingMask key="autoresizingMask"/>
-                                    <subviews>
-                                        <label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Z3y-WW-606">
-                                            <rect key="frame" x="16" y="0.0" width="324" height="59.5"/>
-                                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
-                                            <fontDescription key="fontDescription" type="system" pointSize="13"/>
-                                            <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-                                            <nil key="highlightedColor"/>
-                                        </label>
-                                    </subviews>
-                                    <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                                </tableViewCellContentView>
-                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                            </tableViewCell>
-                        </prototypes>
-                        <connections>
-                            <outlet property="dataSource" destination="r57-Y0-NGA" id="Ri8-7Y-4Eb"/>
-                            <outlet property="delegate" destination="r57-Y0-NGA" id="NFD-Pt-S38"/>
-                        </connections>
-                    </tableView>
-                    <toolbarItems>
-                        <barButtonItem title="Create" id="POg-4h-6PE">
-                            <connections>
-                                <action selector="create:" destination="r57-Y0-NGA" id="osR-ef-mcW"/>
-                            </connections>
-                        </barButtonItem>
-                        <barButtonItem style="plain" systemItem="flexibleSpace" id="W6q-bt-WEv"/>
-                        <barButtonItem title="Move" id="lHO-dx-i7G">
-                            <connections>
-                                <action selector="move:" destination="r57-Y0-NGA" id="Lrp-5d-IUd"/>
-                            </connections>
-                        </barButtonItem>
-                    </toolbarItems>
-                    <navigationItem key="navigationItem" id="6DA-qZ-eT5">
-                        <barButtonItem key="rightBarButtonItem" title="Cancel" id="YzK-6z-T0K">
-                            <connections>
-                                <action selector="cancel:" destination="r57-Y0-NGA" id="lSc-Ic-ZvZ"/>
-                            </connections>
-                        </barButtonItem>
-                    </navigationItem>
-                    <connections>
-                        <outlet property="cancel" destination="YzK-6z-T0K" id="ieh-Qu-oWw"/>
-                        <outlet property="create" destination="POg-4h-6PE" id="UyP-ep-sWK"/>
-                        <outlet property="move" destination="lHO-dx-i7G" id="8iF-b5-5v2"/>
-                    </connections>
-                </tableViewController>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="WJJ-7C-06z" userLabel="First Responder" sceneMemberID="firstResponder"/>
-            </objects>
-            <point key="canvasLocation" x="8901" y="-447"/>
-        </scene>
-        <!--Navigation Controller-->
-        <scene sceneID="XhT-lY-9Eo">
-            <objects>
-                <navigationController automaticallyAdjustsScrollViewInsets="NO" toolbarHidden="NO" id="GGi-ld-Icm" sceneMemberID="viewController">
-                    <toolbarItems/>
-                    <navigationItem key="navigationItem" id="uMb-zy-0sS"/>
-                    <navigationBar key="navigationBar" alpha="0.89999997615814209" contentMode="scaleToFill" misplaced="YES" translucent="NO" id="emo-5L-Jsr">
-                        <rect key="frame" x="0.0" y="20" width="375" height="44"/>
-                        <autoresizingMask key="autoresizingMask"/>
-                    </navigationBar>
-                    <nil name="viewControllers"/>
-                    <toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" alpha="0.89999997615814209" contentMode="scaleToFill" translucent="NO" id="rcA-x8-dow">
-                        <rect key="frame" x="0.0" y="623" width="375" height="44"/>
-                        <autoresizingMask key="autoresizingMask"/>
-                    </toolbar>
-                    <connections>
-                        <segue destination="r57-Y0-NGA" kind="relationship" relationship="rootViewController" id="ASc-lI-Ps1"/>
-                    </connections>
-                </navigationController>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="gU9-pc-48i" userLabel="First Responder" sceneMemberID="firstResponder"/>
-            </objects>
-            <point key="canvasLocation" x="8089" y="-447"/>
-        </scene>
-    </scenes>
-</document>

+ 903 - 0
Share/NCShareExtension.swift

@@ -0,0 +1,903 @@
+//
+//  NCShareExtension.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 20/04/2021.
+//  Copyright © 2021 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  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
+import NCCommunication
+
+class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDelegate, NCRenameFileDelegate, NCAccountRequestDelegate {
+    
+    @IBOutlet weak var collectionView: UICollectionView!
+    @IBOutlet weak var tableView: UITableView!
+    @IBOutlet weak var cancelButton: UIBarButtonItem!
+    @IBOutlet weak var separatorView: UIView!
+    @IBOutlet weak var commandView: UIView!
+    @IBOutlet weak var separatorHeightConstraint: NSLayoutConstraint!
+    @IBOutlet weak var commandViewHeightConstraint: NSLayoutConstraint!
+    
+    @IBOutlet weak var createFolderView: UIView!
+    @IBOutlet weak var createFolderImage: UIImageView!
+    @IBOutlet weak var createFolderLabel: UILabel!
+
+    @IBOutlet weak var uploadView: UIView!
+    @IBOutlet weak var uploadImage: UIImageView!
+    @IBOutlet weak var uploadLabel: UILabel!
+    
+    // -------------------------------------------------------------
+    var serverUrl = ""
+    var filesName: [String] = []
+    // -------------------------------------------------------------
+        
+    private var emptyDataSet: NCEmptyDataSet?
+    private let keyLayout = NCGlobal.shared.layoutViewShareExtension
+    private var metadataFolder: tableMetadata?
+    private var networkInProgress = false
+    private var dataSource = NCDataSource()
+
+    private var layoutForView: NCGlobal.layoutForViewType?
+  
+    private var heightRowTableView: CGFloat = 50
+    private var heightCommandView: CGFloat = 170
+    
+    private var autoUploadFileName = ""
+    private var autoUploadDirectory = ""
+    
+    private let refreshControl = UIRefreshControl()
+    private var activeAccount: tableAccount!
+    private let chunckSize = CCUtility.getChunkSize() * 1000000
+    
+    // MARK: - View Life Cycle
+
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        
+        self.navigationController?.navigationBar.prefersLargeTitles = false
+        
+        // Cell
+        collectionView.register(UINib.init(nibName: "NCListCell", bundle: nil), forCellWithReuseIdentifier: "listCell")
+        collectionView.collectionViewLayout = NCListLayout()
+
+        // Add Refresh Control
+        collectionView.addSubview(refreshControl)
+        refreshControl.tintColor = NCBrandColor.shared.brandText
+        refreshControl.backgroundColor = NCBrandColor.shared.systemBackground
+        refreshControl.addTarget(self, action: #selector(reloadDatasource), for: .valueChanged)
+        
+        // Command view
+        commandView.backgroundColor = NCBrandColor.shared.secondarySystemBackground
+        separatorView.backgroundColor = NCBrandColor.shared.separator
+        separatorHeightConstraint.constant = 0.5
+        
+        // Table view
+        tableView.separatorColor = NCBrandColor.shared.separator
+        tableView.layer.cornerRadius = 10
+        tableView.tableFooterView = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 0, height: 1)))
+
+        // Create folder
+        createFolderView.layer.cornerRadius = 10
+        createFolderImage.image = NCUtility.shared.loadImage(named: "folder.badge.plus", color: NCBrandColor.shared.label)
+        createFolderLabel.text = NSLocalizedString("_create_folder_", comment: "")
+        let createFolderGesture = UITapGestureRecognizer(target: self, action:  #selector(actionCreateFolder))
+        createFolderView.addGestureRecognizer(createFolderGesture)
+        
+        // Upload
+        uploadView.layer.cornerRadius = 10
+        //uploadImage.image = NCUtility.shared.loadImage(named: "square.and.arrow.up", color: NCBrandColor.shared.label)
+        uploadLabel.text = NSLocalizedString("_upload_", comment: "")
+        uploadLabel.textColor = .systemBlue
+        let uploadGesture = UITapGestureRecognizer(target: self, action:  #selector(actionUpload))
+        uploadView.addGestureRecognizer(uploadGesture)
+                
+        // LOG
+        let levelLog = CCUtility.getLogLevel()
+        let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
+        let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
+        
+        NCCommunicationCommon.shared.levelLog = levelLog
+        if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
+            NCCommunicationCommon.shared.pathLog = pathDirectoryGroup
+        }
+        if isSimulatorOrTestFlight {
+            NCCommunicationCommon.shared.writeLog("Start session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
+        } else {
+            NCCommunicationCommon.shared.writeLog("Start session with level \(levelLog) " + versionNextcloudiOS)
+        }
+    }
+    
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        
+        if serverUrl == "" {
+        
+            if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
+                
+                setAccount(account: activeAccount.account)
+                getFilesExtensionContext { (filesName, error) in
+                    DispatchQueue.main.async {
+                        self.filesName = filesName
+                        self.setCommandView()
+                    }
+                }
+                
+            } else {
+                
+                let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: NSLocalizedString("_no_active_account_", comment: ""), preferredStyle: .alert)
+                alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in
+                    self.extensionContext?.completeRequest(returningItems: self.extensionContext?.inputItems, completionHandler: nil)
+                }))
+                self.present(alertController, animated: true)
+            }
+        }
+    }
+    
+    override func viewDidDisappear(_ animated: Bool) {        
+    }
+    
+    override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
+        super.viewWillTransition(to: size, with: coordinator)
+        
+        coordinator.animate(alongsideTransition: nil) { _ in
+            self.collectionView?.collectionViewLayout.invalidateLayout()
+        }
+    }
+    
+    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
+        super.traitCollectionDidChange(previousTraitCollection)
+        
+        collectionView.reloadData()
+        tableView.reloadData()
+    }
+    
+    // MARK: -
+
+    func setAccount(account: String) {
+        
+        guard let activeAccount = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)) else {
+            extensionContext?.completeRequest(returningItems: extensionContext?.inputItems, completionHandler: nil)
+            return
+        }
+        self.activeAccount = activeAccount
+        
+        // NETWORKING
+        NCCommunicationCommon.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account), urlBase: activeAccount.urlBase, userAgent: CCUtility.getUserAgent(), webDav: NCUtilityFileSystem.shared.getWebDAV(account: activeAccount.account), dav: NCUtilityFileSystem.shared.getDAV(), nextcloudVersion: 0, delegate: NCNetworking.shared)
+                
+        // get auto upload folder
+        autoUploadFileName = NCManageDatabase.shared.getAccountAutoUploadFileName()
+        autoUploadDirectory = NCManageDatabase.shared.getAccountAutoUploadDirectory(urlBase: activeAccount.urlBase, account: activeAccount.account)
+        
+        serverUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, account: activeAccount.account)
+        
+        layoutForView = NCUtility.shared.getLayoutForView(key: keyLayout,serverUrl: serverUrl)
+            
+        reloadDatasource(withLoadFolder: true)
+        setNavigationBar(navigationTitle: NCBrandOptions.shared.brand)
+    }
+    
+    func setNavigationBar(navigationTitle: String) {
+        
+        navigationItem.title = navigationTitle
+        cancelButton.title = NSLocalizedString("_cancel_", comment: "")
+
+        // BACK BUTTON
+
+        let backButton = UIButton(type: .custom)
+        backButton.setImage(UIImage(named: "back"), for: .normal)
+        backButton.tintColor = .systemBlue
+        backButton.semanticContentAttribute = .forceLeftToRight
+        backButton.setTitle(" "+NSLocalizedString("_back_", comment: ""), for: .normal)
+        backButton.setTitleColor(.systemBlue, for: .normal)
+        backButton.addTarget(self, action: #selector(backButtonTapped(sender:)), for: .touchUpInside)
+        
+        // PROFILE BUTTON
+                
+        var image = NCUtility.shared.loadImage(named: "person.crop.circle")
+        let fileNamePath = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(activeAccount.user, urlBase: activeAccount.urlBase)) + "-" + activeAccount.user + ".png"
+        if let userImage = UIImage(contentsOfFile: fileNamePath) {
+            image = userImage
+        }
+            
+        image = NCUtility.shared.createAvatar(image: image, size: 30)
+            
+        let profileButton = UIButton(type: .custom)
+        profileButton.setImage(image, for: .normal)
+            
+        if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, account: activeAccount.account) {
+             
+
+            var title = "  "
+            if activeAccount?.alias == "" {
+                title = title + (activeAccount?.user ?? "")
+            } else {
+                title = title + (activeAccount?.alias ?? "")
+            }
+                
+            profileButton.setTitle(title, for: .normal)
+            profileButton.setTitleColor(.systemBlue, for: .normal)
+        }
+            
+        profileButton.semanticContentAttribute = .forceLeftToRight
+        profileButton.sizeToFit()
+        profileButton.addTarget(self, action: #selector(profileButtonTapped(sender:)), for: .touchUpInside)
+                   
+        if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, account: activeAccount.account) {
+
+            navigationItem.setLeftBarButtonItems([UIBarButtonItem(customView: profileButton)], animated: true)
+            
+        } else {
+
+            let space = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
+            space.width = 20
+            
+            navigationItem.setLeftBarButtonItems([UIBarButtonItem(customView: backButton), space, UIBarButtonItem(customView: profileButton)], animated: true)
+        }
+    }
+    
+    func setCommandView() {
+                
+        var counter: CGFloat = 0
+        
+        if filesName.count == 0 {
+            self.extensionContext?.completeRequest(returningItems: self.extensionContext?.inputItems, completionHandler: nil)
+            return
+        } else {
+            if filesName.count < 3 {
+                counter = CGFloat(filesName.count)
+                self.commandViewHeightConstraint.constant = heightCommandView + (self.heightRowTableView * counter)
+            } else  {
+                counter = 3
+                self.commandViewHeightConstraint.constant = heightCommandView + (self.heightRowTableView * counter)
+            }
+            if filesName.count <= 3 {
+                self.tableView.isScrollEnabled = false
+            }
+            // Empty
+            emptyDataSet = NCEmptyDataSet.init(view: collectionView, offset: -50*counter, delegate: self)
+            self.tableView.reloadData()
+        }
+    }
+    
+    // MARK: - Empty
+    
+    func emptyDataSetView(_ view: NCEmptyView) {
+                
+        if networkInProgress {
+            view.emptyImage.image = UIImage.init(named: "networkInProgress")?.image(color: .gray, size: UIScreen.main.bounds.width)
+            view.emptyTitle.text = NSLocalizedString("_request_in_progress_", comment: "")
+            view.emptyDescription.text = ""
+        } else {
+            view.emptyImage.image = UIImage.init(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width)
+            view.emptyTitle.text = NSLocalizedString("_files_no_folders_", comment: "")
+            view.emptyDescription.text = ""
+        }
+    }
+    
+    // MARK: ACTION
+    
+    @IBAction func actionCancel(_ sender: UIBarButtonItem) {
+        extensionContext?.completeRequest(returningItems: extensionContext?.inputItems, completionHandler: nil)
+    }
+    
+    @objc func actionCreateFolder() {
+        
+        let alertController = UIAlertController(title: NSLocalizedString("_create_folder_", comment: ""), message:"", preferredStyle: .alert)
+        
+        alertController.addTextField { (textField) in
+            textField.autocapitalizationType = UITextAutocapitalizationType.words
+        }
+        
+        let actionSave = UIAlertAction(title: NSLocalizedString("_save_", comment: ""), style: .default) { (action:UIAlertAction) in
+            if let fileName = alertController.textFields?.first?.text  {
+                self.createFolder(with: fileName)
+            }
+        }
+        
+        let actionCancel = UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel) { (action:UIAlertAction) in
+            print("You've pressed cancel button")
+        }
+        
+        alertController.addAction(actionSave)
+        alertController.addAction(actionCancel)
+        
+        self.present(alertController, animated: true, completion:nil)
+    }
+    
+    @objc func actionUpload() {
+        
+        if let fileName = filesName.first {
+            
+            filesName.removeFirst()
+            let ocId = NSUUID().uuidString
+            let filePath = CCUtility.getDirectoryProviderStorageOcId(ocId, fileNameView: fileName)!
+                
+            if NCUtilityFileSystem.shared.moveFile(atPath: (NSTemporaryDirectory() + fileName), toPath: filePath) {
+                
+                NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: true)
+                                
+                let metadata = NCManageDatabase.shared.createMetadata(account: activeAccount.account, fileName: fileName, fileNameView: fileName, ocId: ocId, serverUrl: serverUrl, urlBase: activeAccount.urlBase, url: "", contentType: "", livePhoto: false)
+                
+                metadata.session = NCCommunicationCommon.shared.sessionIdentifierUpload
+                metadata.sessionSelector = NCGlobal.shared.selectorUploadFile
+                metadata.size = NCUtilityFileSystem.shared.getFileSize(filePath: filePath)
+                metadata.status = NCGlobal.shared.metadataStatusWaitUpload
+            
+                // E2EE
+                if CCUtility.isFolderEncrypted(metadata.serverUrl, e2eEncrypted: metadata.e2eEncrypted, account: metadata.account, urlBase: metadata.urlBase) {
+                    metadata.e2eEncrypted = true
+                }
+                
+                // CHUNCK
+                if chunckSize != 0 && metadata.size > chunckSize {
+                    metadata.chunk = true
+                }
+                
+                NCNetworking.shared.upload(metadata: metadata) {
+                    
+                } completion: { (errorCode, errorDescription) in
+                    
+                    NCUtility.shared.stopActivityIndicator()
+                    
+                    if errorCode == 0 {
+                        self.actionUpload()
+                    } else {
+                        
+                        NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", ocId))
+                        NCManageDatabase.shared.deleteChunks(account: self.activeAccount.account, ocId: ocId)
+                        
+                        let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: errorDescription, preferredStyle: .alert)
+                        alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in
+                            self.extensionContext?.completeRequest(returningItems: self.extensionContext?.inputItems, completionHandler: nil)
+                            return
+                        }))
+                        self.present(alertController, animated: true)
+                    }
+                }
+            }
+        } else {
+            extensionContext?.completeRequest(returningItems: extensionContext?.inputItems, completionHandler: nil)
+            return
+        }
+    }
+    
+    @objc func backButtonTapped(sender: Any) {
+                
+        while serverUrl.last != "/" {
+            serverUrl.removeLast()
+        }
+        serverUrl.removeLast()
+
+        reloadDatasource(withLoadFolder: true)
+        
+        var navigationTitle = (serverUrl as NSString).lastPathComponent
+        if NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, account: activeAccount.account) == serverUrl {
+            navigationTitle = NCBrandOptions.shared.brand
+        }
+        setNavigationBar(navigationTitle: navigationTitle)
+    }
+    
+    func rename(fileName: String, fileNameNew: String) {
+        
+        if let row = self.filesName.firstIndex(where: {$0 == fileName}) {
+            
+            if NCUtilityFileSystem.shared.moveFile(atPath: (NSTemporaryDirectory() + fileName), toPath: (NSTemporaryDirectory() + fileNameNew)) {
+                filesName[row] = fileNameNew
+                tableView.reloadData()
+            }
+        }
+    }
+    
+    @objc func renameButtonPressed(sender: NCShareExtensionButtonWithIndexPath) {
+        
+        if let fileName = sender.fileName {
+            if let vcRename = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile {
+            
+                vcRename.delegate = self
+                vcRename.fileName = fileName
+                vcRename.imagePreview = sender.image
+
+                let popup = NCPopupViewController(contentController: vcRename, popupWidth: vcRename.width, popupHeight: vcRename.height)
+                                        
+                self.present(popup, animated: true)
+            }
+        }
+    }
+    
+    func accountRequestChangeAccount(account: String) {
+        setAccount(account: account)
+    }
+    
+    @objc func profileButtonTapped(sender: Any) {
+        
+        let accounts = NCManageDatabase.shared.getAllAccountOrderAlias()
+        if accounts.count > 1 {
+            
+            if let vcAccountRequest = UIStoryboard(name: "NCAccountRequest", bundle: nil).instantiateInitialViewController() as? NCAccountRequest {
+               
+                // Only here change the active account 
+                for account in accounts {
+                    if account.account == self.activeAccount.account {
+                        account.active = true
+                    } else {
+                        account.active = false
+                    }
+                }
+                
+                vcAccountRequest.activeAccount = self.activeAccount
+                vcAccountRequest.accounts = accounts.sorted { (sorg, dest) -> Bool in
+                    return sorg.active && !dest.active
+                }
+                vcAccountRequest.enableTimerProgress = false
+                vcAccountRequest.enableAddAccount = false
+                vcAccountRequest.delegate = self
+                vcAccountRequest.dismissDidEnterBackground = true
+
+                let screenHeighMax = UIScreen.main.bounds.height - (UIScreen.main.bounds.height/5)
+                let numberCell = accounts.count
+                let height = min(CGFloat(numberCell * Int(vcAccountRequest.heightCell) + 45), screenHeighMax)
+                
+                let popup = NCPopupViewController(contentController: vcAccountRequest, popupWidth: 300, popupHeight: height+20)
+                
+                self.present(popup, animated: true)
+            }
+        }
+    }
+}
+
+// MARK: - Collection View
+
+extension NCShareExtension: UICollectionViewDelegate {
+
+    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+        
+        if let metadata = dataSource.cellForItemAt(indexPath: indexPath) {
+            if let serverUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)  {
+                
+                if metadata.e2eEncrypted && !CCUtility.isEnd(toEndEnabled: activeAccount.account) {
+                    let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: NSLocalizedString("_e2e_goto_settings_for_enable_", comment: ""), preferredStyle: .alert)
+                    alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
+                    self.present(alertController, animated: true)
+                    return
+                }
+                
+                self.serverUrl = serverUrl
+                reloadDatasource(withLoadFolder: true)
+                setNavigationBar(navigationTitle: metadata.fileNameView)
+            }
+        }
+    }
+}
+
+extension NCShareExtension: UICollectionViewDataSource {
+
+    func numberOfSections(in collectionView: UICollectionView) -> Int {
+        return 1
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+        let numberOfItems = dataSource.numberOfItems()
+        emptyDataSet?.numberOfItemsInSection(numberOfItems, section:section)
+        return numberOfItems
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+        
+        guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else {
+            return collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
+        }
+        
+        var tableShare: tableShare?
+        var isShare = false
+        var isMounted = false
+        
+        // Download preview
+        NCOperationQueue.shared.downloadThumbnail(metadata: metadata, urlBase: activeAccount.urlBase, view: collectionView, indexPath: indexPath)
+        
+        if let metadataFolder = metadataFolder {
+            isShare = metadata.permissions.contains(NCGlobal.shared.permissionShared) && !metadataFolder.permissions.contains(NCGlobal.shared.permissionShared)
+            isMounted = metadata.permissions.contains(NCGlobal.shared.permissionMounted) && !metadataFolder.permissions.contains(NCGlobal.shared.permissionMounted)
+        }
+        
+        if dataSource.metadataShare[metadata.ocId] != nil {
+            tableShare = dataSource.metadataShare[metadata.ocId]
+        }
+            
+        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
+        cell.delegate = self
+        
+        cell.objectId = metadata.ocId
+        cell.indexPath = indexPath
+        cell.labelTitle.text = metadata.fileNameView
+        cell.labelTitle.textColor = NCBrandColor.shared.label
+        
+        cell.imageSelect.image = nil
+        cell.imageStatus.image = nil
+        cell.imageLocal.image = nil
+        cell.imageFavorite.image = nil
+        cell.imageShared.image = nil
+        cell.imageMore.image = nil
+        
+        cell.imageItem.image = nil
+        cell.imageItem.backgroundColor = nil
+        
+        cell.progressView.progress = 0.0
+        
+        if metadata.directory {
+            
+            if metadata.e2eEncrypted {
+                cell.imageItem.image = NCBrandColor.cacheImages.folderEncrypted
+            } else if isShare {
+                cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe
+            } else if (tableShare != nil && tableShare?.shareType != 3) {
+                cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe
+            } else if (tableShare != nil && tableShare?.shareType == 3) {
+                cell.imageItem.image = NCBrandColor.cacheImages.folderPublic
+            } else if metadata.mountType == "group" {
+                cell.imageItem.image = NCBrandColor.cacheImages.folderGroup
+            } else if isMounted {
+                cell.imageItem.image = NCBrandColor.cacheImages.folderExternal
+            } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory {
+                cell.imageItem.image = NCBrandColor.cacheImages.folderAutomaticUpload
+            } else {
+                cell.imageItem.image = NCBrandColor.cacheImages.folder
+            }
+            
+            cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
+            
+            let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
+            let tableDirectory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", activeAccount.account, lockServerUrl))
+            
+            // Local image: offline
+            if tableDirectory != nil && tableDirectory!.offline {
+                cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
+            }
+            
+        }
+        
+        // image Favorite
+        if metadata.favorite {
+            cell.imageFavorite.image = NCBrandColor.cacheImages.favorite
+        }
+        
+        // Share image
+        if (isShare) {
+            cell.imageShared.image = NCBrandColor.cacheImages.shared
+        } else if (tableShare != nil && tableShare?.shareType == 3) {
+            cell.imageShared.image = NCBrandColor.cacheImages.shareByLink
+        } else if (tableShare != nil && tableShare?.shareType != 3) {
+            cell.imageShared.image = NCBrandColor.cacheImages.shared
+        } else {
+            cell.imageShared.image = NCBrandColor.cacheImages.canShare
+        }
+        if metadata.ownerId.count > 0 && metadata.ownerId != activeAccount.userId {
+            let fileNameUser = String(CCUtility.getDirectoryUserData()) + "/" + String(CCUtility.getStringUser(activeAccount.user, urlBase: activeAccount.urlBase)) + "-" + metadata.ownerId + ".png"
+            if FileManager.default.fileExists(atPath: fileNameUser) {
+                cell.imageShared.image = UIImage(contentsOfFile: fileNameUser)
+            } else {
+                NCCommunication.shared.downloadAvatar(userId: metadata.ownerId, fileNameLocalPath: fileNameUser, size: NCGlobal.shared.avatarSize) { (account, data, errorCode, errorMessage) in
+                    if errorCode == 0 && account == self.activeAccount.account {
+                        cell.imageShared.image = UIImage(contentsOfFile: fileNameUser)
+                    }
+                }
+            }
+        }
+        
+        cell.imageSelect.isHidden = true
+        cell.backgroundView = nil
+        cell.hideButtonMore(true)
+        cell.hideButtonShare(true)
+        cell.selectMode(false)
+
+        // Live Photo
+        if metadata.livePhoto {
+            cell.imageStatus.image = NCBrandColor.cacheImages.livePhoto
+        }
+        
+        // Remove last separator
+        if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 {
+            cell.separator.isHidden = true
+        } else {
+            cell.separator.isHidden = false
+        }
+        
+        return cell
+    }
+}
+
+// MARK: - Table View
+
+extension NCShareExtension: UITableViewDelegate {
+    
+    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        return heightRowTableView
+    }
+    
+    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+    }
+}
+
+extension NCShareExtension: UITableViewDataSource {
+    
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        filesName.count
+    }
+    
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+               
+        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
+        cell.backgroundColor = NCBrandColor.shared.systemBackground
+        
+        let imageCell = cell.viewWithTag(10) as? UIImageView
+        let fileNameCell = cell.viewWithTag(20) as? UILabel
+        let renameButton = cell.viewWithTag(30) as? NCShareExtensionButtonWithIndexPath
+
+        imageCell?.layer.cornerRadius = 6
+        imageCell?.layer.masksToBounds = true
+
+        let fileName = filesName[indexPath.row]
+        let resultInternalType = NCCommunicationCommon.shared.getInternalType(fileName: fileName, mimeType: "", directory: false)
+                
+        if let image = UIImage(contentsOfFile: (NSTemporaryDirectory() + fileName)) {
+            imageCell?.image = image
+        } else {
+            if resultInternalType.iconName.count > 0 {
+                imageCell?.image = UIImage.init(named: resultInternalType.iconName)
+            } else {
+                imageCell?.image = NCBrandColor.cacheImages.file
+            }
+        }
+        
+        fileNameCell?.text = fileName
+        
+        renameButton?.setImage(NCUtility.shared.loadImage(named: "pencil").image(color: NCBrandColor.shared.label, size: 15), for: .normal)
+        renameButton?.indexPath = indexPath
+        renameButton?.fileName = fileName
+        renameButton?.image = imageCell?.image
+        renameButton?.addTarget(self, action:#selector(renameButtonPressed(sender:)), for: .touchUpInside)
+
+        return cell
+    }
+}
+
+// MARK: - NC API & Algorithm
+
+extension NCShareExtension {
+
+    @objc func reloadDatasource(withLoadFolder: Bool) {
+                
+        layoutForView = NCUtility.shared.getLayoutForView(key: keyLayout, serverUrl: serverUrl)
+                
+        let metadatasSource = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND directory == true", activeAccount.account, serverUrl))
+        self.dataSource = NCDataSource.init(metadatasSource: metadatasSource, sort: layoutForView?.sort, ascending: layoutForView?.ascending, directoryOnTop: layoutForView?.directoryOnTop, favoriteOnTop: true, filterLivePhoto: true)
+        
+        if withLoadFolder {
+            loadFolder()
+        } else {
+            self.refreshControl.endRefreshing()
+        }
+        
+        collectionView.reloadData()
+    }
+    
+    func createFolder(with fileName: String) {
+        
+        NCNetworking.shared.createFolder(fileName: fileName, serverUrl: serverUrl, account: activeAccount.account, urlBase: activeAccount.urlBase) { (errorCode, errorDescription) in
+            
+            if errorCode == 0 {
+                self.reloadDatasource(withLoadFolder: true)
+            }  else {
+                let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: errorDescription, preferredStyle: .alert)
+                alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
+                self.present(alertController, animated: true)
+            }
+        }
+    }
+    
+    func loadFolder() {
+        
+        networkInProgress = true
+        collectionView.reloadData()
+        
+        NCNetworking.shared.readFolder(serverUrl: serverUrl, account: activeAccount.account) { (_, metadataFolder, _, _, _, errorCode, errorDescription) in
+            if errorCode != 0 {
+                let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: errorDescription, preferredStyle: .alert)
+                alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
+                self.present(alertController, animated: true)
+            }
+            self.networkInProgress = false
+            self.metadataFolder = metadataFolder
+            self.reloadDatasource(withLoadFolder: false)
+        }
+    }
+    
+    func getFilesExtensionContext(completion: @escaping (_ filesName: [String], _ error: Error?)->())  {
+        
+        var filesName: [String] = []
+        var conuter = 0
+        var outError: Error? = nil
+        
+        CCUtility.emptyTemporaryDirectory()
+                
+        if let inputItems : [NSExtensionItem] = extensionContext?.inputItems as? [NSExtensionItem] {
+            
+            for item : NSExtensionItem in inputItems {
+                
+                if let attachments = item.attachments {
+                    
+                    if attachments.isEmpty {
+                        
+                        extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
+                        completion(filesName, outError)
+                        return
+                    }
+                    
+                    for (index, current) in (attachments.enumerated()) {
+                        
+                        if current.hasItemConformingToTypeIdentifier(kUTTypeItem as String) || current.hasItemConformingToTypeIdentifier("public.url") {
+                            
+                            var typeIdentifier = ""
+                            if current.hasItemConformingToTypeIdentifier(kUTTypeItem as String) { typeIdentifier = kUTTypeItem as String }
+                            if current.hasItemConformingToTypeIdentifier("public.url") { typeIdentifier = "public.url" }
+                            
+                            current.loadItem(forTypeIdentifier: typeIdentifier, options: nil, completionHandler: {(item, error) -> Void in
+                                
+                                var fileNameOriginal: String?
+                                var fileName: String = ""
+                                
+                                let dateFormatter = DateFormatter()
+                                dateFormatter.dateFormat = "yyyy-MM-dd HH-mm-ss-"
+                                conuter += 1
+                                
+                                if let url = item as? NSURL {
+                                    fileNameOriginal = url.lastPathComponent!
+                                }
+                                
+                                if error == nil {
+                                                                        
+                                    if let image = item as? UIImage {
+                                        
+                                        print("item as UIImage")
+                                        
+                                        if let pngImageData = image.pngData() {
+                                        
+                                            if fileNameOriginal != nil {
+                                                fileName =  fileNameOriginal!
+                                            } else {
+                                                fileName = "\(dateFormatter.string(from: Date()))\(conuter).png"
+                                            }
+                                            
+                                            let filenamePath = NSTemporaryDirectory() + fileName
+                                            
+                                            let result = (try? pngImageData.write(to: URL(fileURLWithPath: filenamePath), options: [.atomic])) != nil
+                                        
+                                            if result {
+                                                filesName.append(fileName)
+                                            }
+                                            
+                                        } else {
+                                         
+                                            print("Error image nil")
+                                        }
+                                    }
+                                    
+                                    if let url = item as? URL {
+                                        
+                                        print("item as url: \(String(describing: item))")
+                                        
+                                        if fileNameOriginal != nil {
+                                            fileName =  fileNameOriginal!
+                                        } else {
+                                            let ext = url.pathExtension
+                                            fileName = "\(dateFormatter.string(from: Date()))\(conuter)." + ext
+                                        }
+                                        
+                                        let filenamePath = NSTemporaryDirectory() + fileName
+                                      
+                                        do {
+                                            try FileManager.default.removeItem(atPath: filenamePath)
+                                        }
+                                        catch { }
+                                        
+                                        do {
+                                            try FileManager.default.copyItem(atPath: url.path, toPath:filenamePath)
+                                            
+                                            do {
+                                                let attr : NSDictionary? = try FileManager.default.attributesOfItem(atPath: filenamePath) as NSDictionary?
+                                                
+                                                if let _attr = attr {
+                                                    if _attr.fileSize() > 0 {
+                                                        
+                                                        filesName.append(fileName)
+                                                    }
+                                                }
+                                                
+                                            } catch let error {
+                                                outError = error
+                                            }
+                                            
+                                        } catch let error {
+                                            outError = error
+                                        }
+                                    }
+                                    
+                                    if let data = item as? Data {
+                                        
+                                        if data.count > 0 {
+                                        
+                                            print("item as NSdata")
+                                        
+                                            if fileNameOriginal != nil {
+                                                fileName =  fileNameOriginal!
+                                            } else {
+                                                let description = current.description
+                                                let fullNameArr = description.components(separatedBy: "\"")
+                                                let fileExtArr = fullNameArr[1].components(separatedBy: ".")
+                                                let pathExtention = (fileExtArr[fileExtArr.count-1]).uppercased()
+                                                fileName = "\(dateFormatter.string(from: Date()))\(conuter).\(pathExtention)"
+                                            }
+                                            
+                                            let filenamePath = NSTemporaryDirectory() + fileName
+                                            
+                                            FileManager.default.createFile(atPath: filenamePath, contents:data, attributes:nil)
+                                                                                
+                                            filesName.append(fileName)
+                                        }
+                                    }
+                                    
+                                    if let data = item as? NSString {
+                                        
+                                        if data.length > 0 {
+                                        
+                                            print("item as NSString")
+                                        
+                                            let fileName = "\(dateFormatter.string(from: Date()))\(conuter).txt"
+                                            let filenamePath = NSTemporaryDirectory() + fileName
+                                        
+                                            FileManager.default.createFile(atPath: filenamePath, contents:data.data(using: String.Encoding.utf8.rawValue), attributes:nil)
+                                        
+                                            filesName.append(fileName)
+                                        }
+                                    }
+                                    
+                                    if index + 1 == attachments.count {
+                                        completion(filesName, outError)
+                                    }
+                                    
+                                } else {
+                                    completion( filesName, error)
+                                }
+                            })
+                        }
+                    } // end for
+                } else {
+                    completion(filesName, outError)
+                }
+            }
+        } else {
+            completion(filesName, outError)
+        }
+    }
+}
+
+class NCShareExtensionButtonWithIndexPath: UIButton {
+    var indexPath:IndexPath?
+    var fileName: String?
+    var image: UIImage?
+}

+ 1 - 1
Share/Share-Bridging-Header.h

@@ -2,5 +2,5 @@
 //  Use this file to import your target's public headers that you would like to expose to Swift.
 //
 
-#import "ShareViewController.h"
 #import "NCEndToEndEncryption.h"
+#import "CCUtility.h"

+ 0 - 42
Share/ShareViewController.h

@@ -1,42 +0,0 @@
-//
-//  ShareViewController.h
-//  Nextcloud iOS
-//
-//  Created by Marino Faggiana on 26/01/16.
-//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  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 "CCCellShareExt.h"
-#import "NCSelectDestination.h"
-
-@interface ShareViewController : UIViewController <UITableViewDelegate, NCSelectDestinationDelegate, UITextFieldDelegate>
-
-@property (nonatomic, strong) NSString *account;
-@property (nonatomic, strong) NSString *urlBase;
-@property (nonatomic, strong) NSString *serverUrl;
-@property (nonatomic, retain) NSMutableArray *filesName;
-
-@property (nonatomic, weak) IBOutlet UITableView *shareTable;
-@property (nonatomic, weak) IBOutlet UIBarButtonItem *destinyFolderButton;
-@property (nonatomic, weak) IBOutlet NSLayoutConstraint *constraintTopTableView;
-@property (nonatomic, weak) IBOutlet UIToolbar *toolBar;
-
-- (void)closeShareViewController;
-- (void)reloadData:(NSArray *)files;
-
-@end

+ 0 - 458
Share/ShareViewController.m

@@ -1,458 +0,0 @@
-//
-//  ShareViewController.m
-//  Nextcloud iOS
-//
-//  Created by Marino Faggiana on 26/01/16.
-//  Copyright (c) 2016 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  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 "ShareViewController.h"
-#import "NCBridgeSwift.h"
-
-@import MobileCoreServices;
-
-@interface ShareViewController () <NCSelectDestinationDelegate>
-{
-    NSURL *dirGroup;
-    NSUInteger totalSize;
-    
-    NSExtensionItem *inputItem;
-    
-    UIColor *barTintColor;
-    UIColor *tintColor;
-    
-    NSString *fileNameOriginal;
-    
-    UIBarButtonItem *rightButtonUpload, *leftButtonCancel;
-}
-@end
-
-@implementation ShareViewController
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== View =====
-#pragma --------------------------------------------------------------------------------------------
-
--(void)viewDidLoad
-{
-    tableAccount *tableAccount = [[NCManageDatabase shared] getAccountActive];
-    
-    if (tableAccount == nil) {
-        
-        // close now
-        [self performSelector:@selector(closeShareViewController) withObject:nil afterDelay:0.1];
-        
-        return;
-        
-    } else {
-        
-        NSInteger serverVersionMajor = [[NCManageDatabase shared] getCapabilitiesServerIntWithAccount:tableAccount.account elements:NCElementsJSON.shared.capabilitiesVersionMajor];
-        NSString *webDav = [[NCUtilityFileSystem shared] getWebDAVWithAccount:tableAccount.account];
-        
-        // LOG
-        NSInteger levelLog = [CCUtility getLogLevel];
-        [[NCCommunicationCommon shared] setLevelLog:levelLog];
-        
-        NSString *pathDirectoryGroup = [[CCUtility getDirectoryGroup] path];
-        [[NCCommunicationCommon shared] setPathLog: pathDirectoryGroup];
-                
-        NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp];
-        [[NCCommunicationCommon shared] writeLog:[NSString stringWithFormat:@"Start session with level %lu %@", (unsigned long)levelLog, versionNextcloudiOS]];
-        
-        // Networking
-        [[NCCommunicationCommon shared] setupWithAccount:tableAccount.account user:tableAccount.user userId:tableAccount.userId password:[CCUtility getPassword:tableAccount.account] urlBase:tableAccount.urlBase userAgent:[CCUtility getUserAgent] webDav:webDav dav:nil nextcloudVersion:serverVersionMajor delegate:[NCNetworking shared]];
-       
-        _account = tableAccount.account;
-        _urlBase = tableAccount.urlBase;
-        
-        if ([_account isEqualToString:[CCUtility getAccountExt]]) {
-            
-            // load
-            
-            _serverUrl = [CCUtility getServerUrlExt];
-            
-            _destinyFolderButton.title = [NSString stringWithFormat:NSLocalizedString(@"_destiny_folder_", nil), [CCUtility getTitleServerUrlExt]];
-            
-        } else {
-            
-            // Default settings
-            
-            [CCUtility setAccountExt:self.account];
-
-            _serverUrl  = [[NCUtilityFileSystem shared] getHomeServerWithUrlBase:tableAccount.urlBase account:tableAccount.account];
-            [CCUtility setServerUrlExt:_serverUrl];
-
-            _destinyFolderButton.title = [NSString stringWithFormat:NSLocalizedString(@"_destiny_folder_", nil), NSLocalizedString(@"_home_", nil)];
-            [CCUtility setTitleServerUrlExt:NSLocalizedString(@"_home_", nil)];
-        }
-    }
-    
-    self.filesName = [[NSMutableArray alloc] init];
-        
-    [self.shareTable registerNib:[UINib nibWithNibName:@"CCCellShareExt" bundle:nil] forCellReuseIdentifier:@"ShareExtCell"];
-    
-    [self navigationBarToolBar];
-    
-    [self loadDataSwift];
-}
-
-- (void)viewWillAppear:(BOOL)animated
-{
-    [super viewWillAppear:animated];
-        
-    self.view.backgroundColor = NCBrandColor.shared.backgroundView;
-    self.shareTable.backgroundColor = NCBrandColor.shared.backgroundView;
-}
-
-- (void)closeShareViewController
-{
-    [self.extensionContext completeRequestReturningItems:self.extensionContext.inputItems completionHandler:nil];
-}
-
-- (void)applicationWillTerminate:(UIApplication *)application
-{
-    NSLog(@"[LOG] bye bye, Nextcloud Share Extension!");
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark == TextField Delegate ==
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)textFieldDidBeginEditing:(UITextField *)textField
-{
-    rightButtonUpload.enabled = false;
-    fileNameOriginal = textField.text;
-}
-
-- (void)textFieldDidEndEditing:(UITextField *)textField
-{
-    rightButtonUpload.enabled = true;
-    NSInteger index = [self.filesName indexOfObject:fileNameOriginal];
-    if (index != NSNotFound) {
-        self.filesName[index] = textField.text;
-    }
-}
-
-- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
-{
-    NSError *error;
-    
-    if ([string isEqualToString:@"\n"]) {
-        
-        //NSString *fileName = [textField.text stringByDeletingPathExtension];
-        NSString *ext = [textField.text pathExtension];
-
-        if (![ext isEqualToString:@""]) {
-            NSString *fileNameAtPath = [NSTemporaryDirectory() stringByAppendingString:fileNameOriginal];
-            NSString *fileNameToPath = [NSTemporaryDirectory() stringByAppendingString:textField.text];
-            
-            [[NSFileManager defaultManager] moveItemAtPath:fileNameAtPath toPath:fileNameToPath error:&error];
-            
-            if (error != nil) {
-                textField.text = fileNameOriginal;
-            }
-        } else {
-            textField.text = fileNameOriginal;
-        }
-        
-        [textField endEditing:true];
-        return false;
-    }
-    
-    return true;
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark == Action ==
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)navigationBarToolBar
-{
-    // Theming
-    if ([NCBrandOptions shared].use_themingColor) {
-        NSString *themingColor = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColor];
-        NSString *themingColorElement = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColorElement];
-        NSString *themingColorText = [[NCManageDatabase shared] getCapabilitiesServerStringWithAccount:self.account elements:NCElementsJSON.shared.capabilitiesThemingColorText];
-        [NCBrandColor.shared settingBrandColor:themingColor themingColorElement:themingColorElement themingColorText:themingColorText];
-    }
-    
-    self.navigationController.navigationBar.barTintColor = NCBrandColor.shared.brand;
-    self.navigationController.navigationBar.tintColor = NCBrandColor.shared.brandText;
-    
-    self.toolBar.barTintColor = NCBrandColor.shared.tabBar;
-    self.toolBar.tintColor = [UIColor grayColor];
-    
-    // Upload
-    rightButtonUpload = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"_save_", nil) style:UIBarButtonItemStylePlain target:self action:@selector(selectPost)];
-    
-    // Cancel
-    leftButtonCancel = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIBarButtonItemStylePlain target:self action:@selector(cancelPost)];
-    
-    // Title
-    [self.navigationController.navigationBar setTitleTextAttributes: @{NSForegroundColorAttributeName:self.navigationController.navigationBar.tintColor}];
-    
-    self.navigationItem.title = [NCBrandOptions shared].brand;
-    self.navigationItem.leftBarButtonItem = leftButtonCancel;
-    self.navigationItem.rightBarButtonItems = [[NSArray alloc] initWithObjects:rightButtonUpload, nil];
-    self.navigationItem.hidesBackButton = YES;
-}
-
-- (void)moveServerUrlTo:(NSString *)serverUrlTo title:(NSString *)title type:(NSString *)type
-{
-    // DENIED e2e
-    if ([CCUtility isFolderEncrypted:serverUrlTo e2eEncrypted:false account:self.account urlBase:self.urlBase]) {
-        return;
-    }
-    
-    if (serverUrlTo)
-        _serverUrl = serverUrlTo;
-    
-    if (title) {
-        self.destinyFolderButton.title = [NSString stringWithFormat:NSLocalizedString(@"_destiny_folder_", nil), title];
-        [CCUtility setTitleServerUrlExt:title];
-    } else {
-        self.destinyFolderButton.title = [NSString stringWithFormat:NSLocalizedString(@"_destiny_folder_", nil), NSLocalizedString(@"_home_", nil)];
-        [CCUtility setTitleServerUrlExt:NSLocalizedString(@"_home_", nil)];
-    }
-    
-    [CCUtility setAccountExt:self.account];
-    [CCUtility setServerUrlExt:_serverUrl];
-}
-
-- (IBAction)destinyFolderButtonTapped:(UIBarButtonItem *)sender
-{
-    UINavigationController* navigationController = [[UIStoryboard storyboardWithName:@"NCSelectDestination" bundle:nil] instantiateInitialViewController];
-    
-    NCSelectDestination *viewController = (NCSelectDestination *)navigationController.topViewController;
-    
-    viewController.delegate = self;
-    viewController.move.title = NSLocalizedString(@"_select_", nil);
-    viewController.tintColor = tintColor;
-    viewController.barTintColor = barTintColor;
-    viewController.tintColorTitle = tintColor;
-    // E2EE
-    viewController.includeDirectoryE2EEncryption = NO;
-
-    [navigationController setModalPresentationStyle:UIModalPresentationFormSheet];
-    [self presentViewController:navigationController animated:YES completion:nil];
-}
-
-- (void)selectPost
-{
-    if ([self.filesName count] > 0) {
-    
-        [[NCUtility shared] startActivityIndicatorWithBackgroundView:nil blurEffect:true bottom:0];
-        
-        NSString *fileName = [self.filesName objectAtIndex:0];
-        NSString *fileNameLocal = [NSTemporaryDirectory() stringByAppendingString:fileName];
-
-        // CONVERSION -->
-        
-        if ([fileName.pathExtension.uppercaseString isEqualToString:@"HEIC"] && [CCUtility getFormatCompatibility]) {
-            UIImage *image = [UIImage imageWithContentsOfFile:fileNameLocal];
-            if (image != nil) {
-                fileName = fileName.stringByDeletingPathExtension;
-                fileName = [NSString stringWithFormat:@"%@.jpg", fileName];
-                [self.filesName replaceObjectAtIndex:0 withObject:fileName];
-                fileNameLocal = [NSTemporaryDirectory() stringByAppendingString:fileName];
-                [UIImageJPEGRepresentation(image, 1.0) writeToFile:fileNameLocal atomically:YES];
-                
-                [self.shareTable reloadData];
-            }
-        }
-        
-        // <--
-        
-        NSString *fileNameForUpload = [[NCUtilityFileSystem shared] createFileName:fileName serverUrl:self.serverUrl account:self.account];
-        NSString *fileNameServer = [NSString stringWithFormat:@"%@/%@", self.serverUrl, fileNameForUpload];
-        
-        [[NCCommunication shared] uploadWithServerUrlFileName:fileNameServer fileNameLocalPath:fileNameLocal dateCreationFile:nil dateModificationFile:nil customUserAgent:nil addCustomHeaders:nil taskHandler:^(NSURLSessionTask *task) {
-                        
-        } progressHandler:^(NSProgress *progress) {
-            
-            
-        } completionHandler:^(NSString *account, NSString *ocId, NSString *etag, NSDate *date, int64_t size, NSDictionary *allHeaderFields, NSInteger errorCode, NSString *errorDescription) {
-            
-            [[NCUtility shared] stopActivityIndicator];
-            [self.filesName removeObject:fileName];
-           
-            if (errorCode == 0) {
-               
-                [CCUtility copyFileAtPath:fileNameLocal toPath:[CCUtility getDirectoryProviderStorageOcId:ocId fileNameView:fileNameForUpload]];
-               
-                tableMetadata *metadata = [[NCManageDatabase shared] createMetadataWithAccount:self.account fileName:fileNameForUpload fileNameView:fileNameForUpload ocId:ocId serverUrl:self.serverUrl urlBase:self.urlBase url:@"" contentType:@"" livePhoto:false chunk:false];
-                               
-                metadata.date = date;
-                metadata.etag = etag;
-                metadata.serverUrl = self.serverUrl;
-                metadata.size = size;
-                
-                [[NCManageDatabase shared] addMetadata:metadata];
-                [[NCManageDatabase shared] addLocalFileWithMetadata:metadata];
-               
-                [self.shareTable performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
-                [self performSelector:@selector(selectPost) withObject:nil];
-               
-            } else {
-               
-                UIAlertController * alert= [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_error_", nil) message: errorDescription preferredStyle:UIAlertControllerStyleAlert];
-                UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
-                                                          handler:^(UIAlertAction * action) {
-                   [alert dismissViewControllerAnimated:YES completion:nil];
-                   [self closeShareViewController];
-                }];
-                [alert addAction:ok];
-                [self presentViewController:alert animated:YES completion:nil];
-            }
-        }];
-        
-    } else {
-        
-        [self closeShareViewController];
-    }
-}
-
-- (void)cancelPost
-{
-    // rimuoviamo i file+ico
-    for (NSString *fileName in self.filesName) {
-        
-        [[NSFileManager defaultManager] removeItemAtPath:[NSTemporaryDirectory() stringByAppendingString:fileName] error:nil];
-    }
-    
-    [self closeShareViewController];
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== Swipe Table DELETE -> menu =====
-#pragma--------------------------------------------------------------------------------------------
-
-- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
-{
-    [self setEditing:NO animated:YES];
-    
-    NSString *fileName = [self.filesName objectAtIndex:indexPath.row];
-    
-    [[NSFileManager defaultManager] removeItemAtPath:[NSTemporaryDirectory() stringByAppendingString:fileName] error:nil];
-
-    [self.filesName removeObjectAtIndex:indexPath.row];
-    
-    if ([self.filesName count] == 0) [self closeShareViewController];
-    else [self.shareTable performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
-}
-
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark == Table ==
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)loadDataSwift
-{
-    CCloadItemData *loadItem = [[CCloadItemData alloc] init];
-    
-    [loadItem loadFiles:NSTemporaryDirectory() extensionContext:self.extensionContext vc:self];
-}
-
-- (void)reloadData:(NSArray *)files
-{
-    totalSize = 0;
-
-    for (NSString *file in files) {
-        
-        NSUInteger fileSize = (NSInteger)[[[NSFileManager defaultManager] attributesOfItemAtPath:[NSTemporaryDirectory() stringByAppendingString:file] error:nil] fileSize];
-        totalSize += fileSize;
-    }
-    
-    if (totalSize > 0) {
-        
-        self.filesName = [[NSMutableArray alloc] initWithArray:files];
-        [self.shareTable reloadData];
-        
-    } else {
-        
-        [self closeShareViewController];
-    }
-}
-
-- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
-{
-    return 80;
-}
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
-{
-    return 1;
-}
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
-{
-    return [self.filesName count];
-}
-
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
-{
-    NSString *fileName = [self.filesName objectAtIndex:indexPath.row];
-    UIImage *image = nil;
-    
-    CCCellShareExt *cell = (CCCellShareExt *)[tableView dequeueReusableCellWithIdentifier:@"ShareExtCell" forIndexPath:indexPath];
-
-    CFStringRef fileExtension = (__bridge CFStringRef)[fileName pathExtension];
-    CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);
-
-    if (UTTypeConformsTo(fileUTI, kUTTypeZipArchive) && [(__bridge NSString *)fileUTI containsString:@"org.openxmlformats"] == NO) image = [UIImage imageNamed:@"file_compress"];
-    else if (UTTypeConformsTo(fileUTI, kUTTypeAudio)) image = [UIImage imageNamed:@"file_audio"];
-    else if (UTTypeConformsTo(fileUTI, kUTTypeMovie)) image = [UIImage imageNamed:@"file_movie"];
-    else if (UTTypeConformsTo(fileUTI, kUTTypeImage)) {
-        image = [UIImage imageWithContentsOfFile:[NSTemporaryDirectory() stringByAppendingString:fileName]];
-        if (image) {
-            image = [image resizeImageWithSize:CGSizeMake(100, 100) isAspectRation:true];
-        } else {
-            image = [UIImage imageNamed:@"file_photo"];
-        }
-    }
-    else if (UTTypeConformsTo(fileUTI, kUTTypeContent)) {
-        
-        image = [UIImage imageNamed:@"document"];
-        
-        NSString *typeFile = (__bridge NSString *)fileUTI;
-        
-        if ([typeFile isEqualToString:@"com.adobe.pdf"]) image = [UIImage imageNamed:@"file_pdf"];
-        if ([typeFile isEqualToString:@"org.openxmlformats.spreadsheetml.sheet"]) image = [UIImage imageNamed:@"file_xls"];
-        if ([typeFile isEqualToString:@"public.plain-text"]) image = [UIImage imageNamed:@"file_txt"];
-    }
-    else image = [UIImage imageNamed:@"file"];
-    
-    NSUInteger fileSize = (NSInteger)[[[NSFileManager defaultManager] attributesOfItemAtPath:[NSTemporaryDirectory() stringByAppendingString:fileName] error:nil] fileSize];
-    
-    cell.fileImageView.image = image;
-
-    cell.fileName.text = fileName;
-    cell.fileName.textColor = NCBrandColor.shared.textView;
-    cell.fileName.delegate = self;
-    
-    cell.info.text = [CCUtility transformedSize:fileSize];
-    cell.info.textColor = NCBrandColor.shared.textView;
-    
-    return cell;
-}
-
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
-{
-    [tableView deselectRowAtIndexPath:indexPath animated:YES];
-}
-
-@end

+ 42 - 29
iOSClient/Account Request/NCAccountRequest.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="V0q-CP-xMJ">
-    <device id="retina6_1" orientation="portrait" appearance="light"/>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="V0q-CP-xMJ">
+    <device id="retina3_5" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -20,51 +20,55 @@
                         <rect key="frame" x="0.0" y="0.0" width="300" height="310"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ouH-gK-Guv" userLabel="Separator">
-                                <rect key="frame" x="0.0" y="102" width="300" height="1"/>
-                                <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                                <constraints>
-                                    <constraint firstAttribute="height" constant="1" id="2OQ-Mt-Gnh"/>
-                                </constraints>
-                            </view>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Accounts" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nZr-nE-ths">
-                                <rect key="frame" x="20" y="64" width="260" height="18"/>
+                                <rect key="frame" x="20" y="15" width="260" height="18"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="QqL-qq-3JI">
+                                <rect key="frame" x="16" y="16.5" width="15" height="15"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="15" id="FJj-0n-59w"/>
+                                    <constraint firstAttribute="width" constant="15" id="FLg-jE-FHJ"/>
+                                </constraints>
+                                <state key="normal" image="xmark"/>
+                                <connections>
+                                    <action selector="actionClose:" destination="V0q-CP-xMJ" eventType="touchUpInside" id="4cX-K8-0C0"/>
+                                </connections>
+                            </button>
                             <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="Pdo-MB-AhU">
-                                <rect key="frame" x="10" y="103" width="280" height="207"/>
+                                <rect key="frame" x="10" y="48" width="280" height="262"/>
                                 <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                                 <prototypes>
-                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="Cell" rowHeight="80" id="Q4K-la-J3W">
-                                        <rect key="frame" x="0.0" y="28" width="280" height="80"/>
+                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="Cell" rowHeight="60" id="Q4K-la-J3W">
+                                        <rect key="frame" x="0.0" y="24.5" width="280" height="60"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Q4K-la-J3W" id="IkA-cK-iZV">
-                                            <rect key="frame" x="0.0" y="0.0" width="280" height="80"/>
+                                            <rect key="frame" x="0.0" y="0.0" width="280" height="60"/>
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" tag="10" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="4cH-oC-YBd" userLabel="Avatar">
-                                                    <rect key="frame" x="0.0" y="20" width="40" height="40"/>
+                                                    <rect key="frame" x="0.0" y="15" width="30" height="30"/>
                                                     <constraints>
-                                                        <constraint firstAttribute="height" constant="40" id="Efd-BU-u61"/>
-                                                        <constraint firstAttribute="width" constant="40" id="qFy-Tu-ov6"/>
+                                                        <constraint firstAttribute="height" constant="30" id="Efd-BU-u61"/>
+                                                        <constraint firstAttribute="width" constant="30" id="qFy-Tu-ov6"/>
                                                     </constraints>
                                                 </imageView>
                                                 <label opaque="NO" userInteractionEnabled="NO" tag="20" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pWI-iZ-BTy" userLabel="User">
-                                                    <rect key="frame" x="50" y="30.5" width="210" height="19.5"/>
+                                                    <rect key="frame" x="40" y="20.5" width="220" height="19.5"/>
                                                     <fontDescription key="fontDescription" type="boldSystem" pointSize="16"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <label opaque="NO" userInteractionEnabled="NO" tag="30" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sWT-NJ-ihR" userLabel="Url">
-                                                    <rect key="frame" x="50" y="57" width="210" height="16"/>
+                                                    <rect key="frame" x="40" y="41" width="220" height="16"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="13"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" tag="40" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="x47-dQ-alI" userLabel="Active">
-                                                    <rect key="frame" x="265" y="32.5" width="15" height="15"/>
+                                                    <rect key="frame" x="265" y="22.5" width="15" height="15"/>
                                                     <constraints>
                                                         <constraint firstAttribute="height" constant="15" id="SXt-LG-c5N"/>
                                                         <constraint firstAttribute="width" constant="15" id="vdZ-4R-gY5"/>
@@ -77,13 +81,14 @@
                                                 <constraint firstItem="x47-dQ-alI" firstAttribute="centerY" secondItem="IkA-cK-iZV" secondAttribute="centerY" id="Ghs-sZ-Bzf"/>
                                                 <constraint firstItem="sWT-NJ-ihR" firstAttribute="leading" secondItem="4cH-oC-YBd" secondAttribute="trailing" constant="10" id="MxV-Du-vUw"/>
                                                 <constraint firstItem="4cH-oC-YBd" firstAttribute="centerY" secondItem="IkA-cK-iZV" secondAttribute="centerY" id="WuT-iT-3xk"/>
+                                                <constraint firstItem="sWT-NJ-ihR" firstAttribute="top" secondItem="pWI-iZ-BTy" secondAttribute="bottom" constant="1" id="ZVm-u7-JGI"/>
                                                 <constraint firstItem="x47-dQ-alI" firstAttribute="leading" secondItem="pWI-iZ-BTy" secondAttribute="trailing" constant="5" id="e8E-uH-gvt"/>
-                                                <constraint firstAttribute="bottom" secondItem="sWT-NJ-ihR" secondAttribute="bottom" constant="7" id="gvc-Ij-KqI"/>
                                                 <constraint firstItem="pWI-iZ-BTy" firstAttribute="centerY" secondItem="IkA-cK-iZV" secondAttribute="centerY" id="jUS-89-RRO"/>
                                                 <constraint firstItem="x47-dQ-alI" firstAttribute="leading" secondItem="sWT-NJ-ihR" secondAttribute="trailing" constant="5" id="lIk-Sj-EgC"/>
                                                 <constraint firstItem="pWI-iZ-BTy" firstAttribute="leading" secondItem="4cH-oC-YBd" secondAttribute="trailing" constant="10" id="mlI-8s-1Ae"/>
                                             </constraints>
                                         </tableViewCellContentView>
+                                        <color key="backgroundColor" systemColor="secondarySystemGroupedBackgroundColor"/>
                                     </tableViewCell>
                                 </prototypes>
                                 <connections>
@@ -96,28 +101,29 @@
                                 <constraints>
                                     <constraint firstAttribute="height" constant="2" id="G3U-2x-imL"/>
                                 </constraints>
+                                <color key="progressTintColor" systemColor="systemBlueColor"/>
                             </progressView>
                         </subviews>
-                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                        <color key="backgroundColor" systemColor="secondarySystemGroupedBackgroundColor"/>
                         <constraints>
                             <constraint firstItem="e8R-j7-ObS" firstAttribute="leading" secondItem="gzh-6E-hc4" secondAttribute="leading" id="1gS-Ca-1Ov"/>
+                            <constraint firstItem="Pdo-MB-AhU" firstAttribute="top" secondItem="nZr-nE-ths" secondAttribute="bottom" constant="15" id="5vV-YC-uzH"/>
                             <constraint firstAttribute="trailing" secondItem="Pdo-MB-AhU" secondAttribute="trailing" constant="10" id="819-yV-vz7"/>
-                            <constraint firstItem="ouH-gK-Guv" firstAttribute="leading" secondItem="gzh-6E-hc4" secondAttribute="leading" id="A6T-ed-97T"/>
                             <constraint firstItem="hTI-Bw-Fws" firstAttribute="top" secondItem="e8R-j7-ObS" secondAttribute="bottom" id="Cko-PC-TiW"/>
                             <constraint firstAttribute="trailing" secondItem="nZr-nE-ths" secondAttribute="trailing" constant="20" id="DPW-MV-oKc"/>
-                            <constraint firstItem="Pdo-MB-AhU" firstAttribute="top" secondItem="ouH-gK-Guv" secondAttribute="bottom" id="HnJ-03-7W5"/>
                             <constraint firstItem="hTI-Bw-Fws" firstAttribute="top" secondItem="Pdo-MB-AhU" secondAttribute="bottom" id="Ife-Ku-hGQ"/>
+                            <constraint firstItem="QqL-qq-3JI" firstAttribute="centerY" secondItem="nZr-nE-ths" secondAttribute="centerY" id="NpU-Hq-gMP"/>
                             <constraint firstItem="nZr-nE-ths" firstAttribute="leading" secondItem="gzh-6E-hc4" secondAttribute="leading" constant="20" id="SI9-xL-6s8"/>
                             <constraint firstItem="Pdo-MB-AhU" firstAttribute="leading" secondItem="gzh-6E-hc4" secondAttribute="leading" constant="10" id="Y5n-ju-hts"/>
                             <constraint firstAttribute="trailing" secondItem="e8R-j7-ObS" secondAttribute="trailing" id="chh-t9-vJN"/>
-                            <constraint firstItem="nZr-nE-ths" firstAttribute="top" secondItem="4vK-ua-S0e" secondAttribute="bottom" constant="20" id="oyJ-sj-j5N"/>
-                            <constraint firstAttribute="trailing" secondItem="ouH-gK-Guv" secondAttribute="trailing" id="r1N-R6-iZg"/>
-                            <constraint firstItem="ouH-gK-Guv" firstAttribute="top" secondItem="nZr-nE-ths" secondAttribute="bottom" constant="20" id="yuT-iN-zVv"/>
+                            <constraint firstItem="QqL-qq-3JI" firstAttribute="leading" secondItem="gzh-6E-hc4" secondAttribute="leading" constant="16" id="gCH-qr-Dyd"/>
+                            <constraint firstItem="nZr-nE-ths" firstAttribute="top" secondItem="4vK-ua-S0e" secondAttribute="bottom" constant="15" id="oyJ-sj-j5N"/>
                         </constraints>
                     </view>
                     <navigationItem key="navigationItem" id="Zon-2j-rsc"/>
                     <size key="freeformSize" width="300" height="310"/>
                     <connections>
+                        <outlet property="closeButton" destination="QqL-qq-3JI" id="6xR-LA-F9H"/>
                         <outlet property="progressView" destination="e8R-j7-ObS" id="2gM-MB-IhE"/>
                         <outlet property="tableView" destination="Pdo-MB-AhU" id="AcD-SW-2ga"/>
                         <outlet property="titleLabel" destination="nZr-nE-ths" id="UbA-Dl-0Ad"/>
@@ -125,12 +131,19 @@
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="qdm-Cl-C5l" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="1453.6231884057972" y="134.59821428571428"/>
+            <point key="canvasLocation" x="1453.125" y="133.75"/>
         </scene>
     </scenes>
     <resources>
+        <image name="xmark" width="24" height="24"/>
+        <systemColor name="secondarySystemGroupedBackgroundColor">
+            <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
         <systemColor name="systemBackgroundColor">
             <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
         </systemColor>
+        <systemColor name="systemBlueColor">
+            <color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
     </resources>
 </document>

+ 58 - 28
iOSClient/Account Request/NCAccountRequest.swift

@@ -21,37 +21,51 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 import NCCommunication
 
+public protocol NCAccountRequestDelegate {
+    func accountRequestAddAccount()
+    func accountRequestChangeAccount(account: String)
+}
+
+// optional func
+public extension NCAccountRequestDelegate {
+    func accountRequestAddAccount() {}
+    func accountRequestChangeAccount(account: String) {}
+}
+
 class NCAccountRequest: UIViewController {
 
     @IBOutlet weak var titleLabel: UILabel!
+    @IBOutlet weak var closeButton: UIButton!
     @IBOutlet weak var tableView: UITableView!
     @IBOutlet weak var progressView: UIProgressView!
     
     public var accounts: [tableAccount] = []
-    public let heightCell: CGFloat = 80
+    public var activeAccount: tableAccount?
+    public let heightCell: CGFloat = 60
     public var enableTimerProgress: Bool = true
     public var enableAddAccount: Bool = false
-    public var viewController: UIViewController?
     public var dismissDidEnterBackground: Bool = false
+    public var delegate: NCAccountRequestDelegate?
 
-    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
     private var timer: Timer?
     private var time: Float = 0
     private let secondsAutoDismiss: Float = 3
     
-    // MARK: - Life Cycle
-    
+    // MARK: - View Life Cycle
+
     override func viewDidLoad() {
         super.viewDidLoad()
         
-        titleLabel.text = NSLocalizedString("_accounts_", comment: "")
+        titleLabel.text = NSLocalizedString("_account_select_", comment: "")
+
+        closeButton.setImage(NCUtility.shared.loadImage(named: "xmark", color: NCBrandColor.shared.label), for: .normal)
         
         tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 1))
+        tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
 
-        progressView.tintColor = NCBrandColor.shared.brandElement
         progressView.trackTintColor = .clear
         progressView.progress = 1
         if enableTimerProgress {
@@ -61,10 +75,9 @@ class NCAccountRequest: UIViewController {
         }
         
         NotificationCenter.default.addObserver(self, selector: #selector(startTimer), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidBecomeActive), object: nil)
-        NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(applicationDidEnterBackground), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidEnterBackground), object: nil)
         
-        changeTheming()        
+        changeTheming()
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -73,6 +86,14 @@ class NCAccountRequest: UIViewController {
     
     override func viewDidAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
+        
+        let visibleCells = tableView.visibleCells
+        var numAccounts = accounts.count
+        if enableAddAccount { numAccounts += 1 }
+        
+        if visibleCells.count == numAccounts {
+            tableView.isScrollEnabled = false
+        }
     }
     
     override func viewWillDisappear(_ animated: Bool) {
@@ -81,15 +102,30 @@ class NCAccountRequest: UIViewController {
         timer?.invalidate()
     }
     
-    // MARK: - NotificationCenter
-
+    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
+        super.traitCollectionDidChange(previousTraitCollection)
+        
+        changeTheming()
+    }
+    
+    // MARK: - Theming
+    
     @objc func changeTheming() {
         
-        view.backgroundColor = NCBrandColor.shared.backgroundForm
-        tableView.backgroundColor = NCBrandColor.shared.backgroundForm
+        view.backgroundColor = NCBrandColor.shared.secondarySystemBackground
+        tableView.backgroundColor = NCBrandColor.shared.secondarySystemBackground
+        
         tableView.reloadData()
     }
     
+    // MARK: - Action
+    
+    @IBAction func actionClose(_ sender: UIButton) {
+        dismiss(animated: true)
+    }
+    
+    // MARK: - NotificationCenter
+
     @objc func applicationDidEnterBackground() {
         
         if dismissDidEnterBackground {
@@ -149,21 +185,14 @@ extension NCAccountRequest: UITableViewDelegate {
         if indexPath.row == accounts.count {
             
             dismiss(animated: true)
-            appDelegate.openLogin(viewController: viewController, selector: NCGlobal.shared.introLogin, openLoginWeb: false)
+            delegate?.accountRequestAddAccount()
             
         } else {
         
             let account = accounts[indexPath.row]
-            if account.account != appDelegate.account {
-                NCManageDatabase.shared.setAccountActive(account.account)
+            if account.account != activeAccount?.account {
                 dismiss(animated: true) {
-                    
-                    NCOperationQueue.shared.cancelAllQueue()
-                    NCNetworking.shared.cancelAllTask()
-                    
-                    self.appDelegate.settingAccount(account.account, urlBase: account.urlBase, user: account.user, userId: account.userId, password: CCUtility.getPassword(account.account))
-                    
-                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+                    self.delegate?.accountRequestChangeAccount(account: account.account)
                 }
             } else {
                 dismiss(animated: true)
@@ -185,8 +214,8 @@ extension NCAccountRequest: UITableViewDataSource {
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
                
         let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
-        cell.backgroundColor = NCBrandColor.shared.backgroundForm
-       
+        cell.backgroundColor = tableView.backgroundColor
+        
         let avatarImage = cell.viewWithTag(10) as? UIImageView
         let userLabel = cell.viewWithTag(20) as? UILabel
         let urlLabel = cell.viewWithTag(30) as? UILabel
@@ -197,11 +226,12 @@ extension NCAccountRequest: UITableViewDataSource {
         
         if indexPath.row == accounts.count {
            
-            avatarImage?.image = NCUtility.shared.loadImage(named: "plus").image(color: .systemBlue, size: 25)
+            avatarImage?.image = NCUtility.shared.loadImage(named: "plus").image(color: .systemBlue, size: 15)
             avatarImage?.contentMode = .center
             userLabel?.text = NSLocalizedString("_add_account_", comment: "")
             userLabel?.textColor = .systemBlue
-            
+            userLabel?.font = UIFont.systemFont(ofSize: 15)
+
         } else {
         
             let account = accounts[indexPath.row]

+ 5 - 5
iOSClient/Activity/NCActivity.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="nhT-TJ-YvX">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="nhT-TJ-YvX">
     <device id="retina5_9" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -17,11 +17,11 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="20" sectionFooterHeight="1" translatesAutoresizingMaskIntoConstraints="NO" id="X49-xg-JXO">
-                                <rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
+                                <rect key="frame" x="0.0" y="0.0" width="375" height="778"/>
                                 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <prototypes>
                                     <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="tableCell" rowHeight="120" id="ggj-aE-fnh" customClass="activityTableViewCell" customModule="Nextcloud" customModuleProvider="target">
-                                        <rect key="frame" x="0.0" y="28" width="375" height="120"/>
+                                        <rect key="frame" x="0.0" y="24.333333969116211" width="375" height="120"/>
                                         <autoresizingMask key="autoresizingMask"/>
                                         <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="ggj-aE-fnh" id="i35-U4-bEk">
                                             <rect key="frame" x="0.0" y="0.0" width="375" height="120"/>
@@ -118,7 +118,7 @@
                         <constraints>
                             <constraint firstItem="USa-eR-a1s" firstAttribute="trailing" secondItem="X49-xg-JXO" secondAttribute="trailing" id="5we-Fh-GVu"/>
                             <constraint firstItem="X49-xg-JXO" firstAttribute="top" secondItem="vOO-VC-ekK" secondAttribute="top" id="SfR-9z-HeQ"/>
-                            <constraint firstAttribute="bottom" secondItem="X49-xg-JXO" secondAttribute="bottom" id="aHq-g4-dUG"/>
+                            <constraint firstItem="USa-eR-a1s" firstAttribute="bottom" secondItem="X49-xg-JXO" secondAttribute="bottom" id="aHq-g4-dUG"/>
                             <constraint firstItem="X49-xg-JXO" firstAttribute="leading" secondItem="USa-eR-a1s" secondAttribute="leading" id="pfF-ag-f7x"/>
                         </constraints>
                     </view>

+ 36 - 23
iOSClient/Activity/NCActivity.swift

@@ -21,7 +21,6 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
 import UIKit
 import SwiftRichString
 import NCCommunication
@@ -45,11 +44,13 @@ class NCActivity: UIViewController, NCEmptyDataSetDelegate {
     var canFetchActivity = true
     var dateAutomaticFetch : Date?
     
+    // MARK: - View Life Cycle
+
     override func viewDidLoad() {
         super.viewDidLoad()
     
         self.navigationController?.navigationBar.prefersLargeTitles = true
-        
+        view.backgroundColor = NCBrandColor.shared.systemBackground
         self.title = NSLocalizedString("_activity_", comment: "")
 
         // Empty
@@ -59,6 +60,7 @@ class NCActivity: UIViewController, NCEmptyDataSetDelegate {
         tableView.separatorColor = UIColor.clear
         tableView.tableFooterView = UIView()
         tableView.contentInset = insets
+        tableView.backgroundColor = NCBrandColor.shared.systemBackground
         
         NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
         
@@ -67,28 +69,33 @@ class NCActivity: UIViewController, NCEmptyDataSetDelegate {
     
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
+        
         appDelegate.activeViewController = self
-
-        loadDataSource()
     }
     
     override func viewDidAppear(_ animated: Bool) {
         super.viewDidAppear(animated)
         
+        NotificationCenter.default.addObserver(self, selector: #selector(initialize), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
+        
+        initialize()
+    }
+    
+    override func viewDidDisappear(_ animated: Bool) {
+        super.viewDidDisappear(animated)
+        
+        NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
+    }
+    
+    // MARK: - NotificationCenter
+
+    @objc func initialize() {
+        loadDataSource()
         loadActivity(idActivity: 0)
     }
     
     @objc func changeTheming() {
-        
-        if filterFileId == nil {
-            view.backgroundColor = NCBrandColor.shared.backgroundView
-            tableView.backgroundColor = NCBrandColor.shared.backgroundView
-            tableView.reloadData()
-        } else {
-            view.backgroundColor = NCBrandColor.shared.backgroundForm
-            tableView.backgroundColor = NCBrandColor.shared.backgroundForm
-            tableView.reloadData()
-        }
+        tableView.reloadData()
     }
     
     // MARK: - Empty
@@ -145,12 +152,12 @@ extension NCActivity: UITableViewDelegate {
     
     func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
         
-        let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.bounds.width, height: 60))
+        let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 60))
         view.backgroundColor = .clear
         
         let label = UILabel()
         label.font = UIFont.boldSystemFont(ofSize: 13)
-        label.textColor = NCBrandColor.shared.textView
+        label.textColor = NCBrandColor.shared.label
         label.text = CCUtility.getTitleSectionDate(sectionDate[section])
         label.textAlignment = .center
         label.layer.cornerRadius = 11
@@ -191,7 +198,7 @@ extension NCActivity: UITableViewDataSource {
             cell.avatar.isHidden = true
             cell.subjectTrailingConstraint.constant = 10
             cell.didSelectItemEnable = self.didSelectItemEnable
-            cell.subject.textColor = NCBrandColor.shared.textView
+            cell.subject.textColor = NCBrandColor.shared.label
             cell.viewController = self
             
             // icon
@@ -312,8 +319,10 @@ extension NCActivity: UITableViewDataSourcePrefetching {
 extension NCActivity: UIScrollViewDelegate {
     
     func scrollViewDidScroll(_ scrollView: UIScrollView) {
-        if (Int(scrollView.contentOffset.y + scrollView.frame.size.height) == Int(scrollView.contentSize.height + scrollView.contentInset.bottom)) {
-            loadActivity(idActivity: allActivities.last!.idActivity)
+        if scrollView.contentSize.height - scrollView.contentOffset.y - scrollView.frame.height < 100 {
+            if let activities = allActivities.last {
+                loadActivity(idActivity: activities.idActivity)
+            }
         }
     }
 }
@@ -329,6 +338,8 @@ extension activityTableViewCell: UICollectionViewDelegate {
             return
         }
         
+        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionCell", for: indexPath) as? activityCollectionViewCell
+        
         let activityPreview = activityPreviews[indexPath.row]
         
         if activityPreview.view == "trashbin" {
@@ -347,7 +358,7 @@ extension activityTableViewCell: UICollectionViewDelegate {
                         viewController.trashPath = result.filePath
                         (responder as? UIViewController)!.navigationController?.pushViewController(viewController, animated: true)
                     } else {
-                        NCContentPresenter.shared.messageNotification("_error_", description: "_trash_file_not_found_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.ErrorInternalError)
+                        NCContentPresenter.shared.messageNotification("_error_", description: "_trash_file_not_found_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorInternalError)
                     }
                 }
             }
@@ -368,7 +379,7 @@ extension activityTableViewCell: UICollectionViewDelegate {
                         let fileSize = attr[FileAttributeKey.size] as! UInt64
                         if fileSize > 0 {
                             if let viewController = self.viewController {
-                                NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata])
+                                NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: cell?.imageView.image)
                             }
                             return
                         }
@@ -415,7 +426,7 @@ extension activityTableViewCell: UICollectionViewDelegate {
                                                        
                             NCManageDatabase.shared.addMetadata(metadata!)
                             if let viewController = self.viewController {
-                                NCViewer.shared.view(viewController: viewController, metadata: metadata!, metadatas: [metadata!])
+                                NCViewer.shared.view(viewController: viewController, metadata: metadata!, metadatas: [metadata!], imageIcon: cell?.imageView.image)
                             }
                         }
                     }
@@ -572,7 +583,9 @@ extension NCActivity {
         canFetchActivity = false
         
         if idActivity > 0 {
-            NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, bottom: 50)
+            
+            let height = self.tabBarController?.tabBar.frame.size.height ?? 0
+            NCUtility.shared.startActivityIndicator(backgroundView: self.view, blurEffect: false, bottom: height + 50, style: .gray)
         }
         
         NCCommunication.shared.getActivity(since: idActivity, limit: 200, objectId: filterFileId, objectType: objectType, previews: true) { (account, activities, errorCode, errorDescription) in

+ 104 - 59
iOSClient/AppDelegate.swift

@@ -29,7 +29,7 @@ import LocalAuthentication
 import Firebase
 
 @UIApplicationMain
-class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, TOPasscodeViewControllerDelegate {
+class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, TOPasscodeViewControllerDelegate, NCAccountRequestDelegate, NCViewCertificateDetailsDelegate {
 
     var backgroundSessionCompletionHandler: (() -> Void)?
     var window: UIWindow?
@@ -49,6 +49,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     var activeServerUrl: String = ""
     @objc var activeViewController: UIViewController?
     var activeViewerVideo: NCViewerVideo?
+    var mainTabBar: NCMainTabBar?
     
     var listFilesVC: [String:NCFiles] = [:]
     var listFavoriteVC: [String:NCFavorite] = [:]
@@ -62,7 +63,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     var pasteboardOcIds: [String] = []
     var shares: [tableShare] = []
     var timerErrorNetworking: Timer?
-
+    
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
         
         let userAgent = CCUtility.getUserAgent() as String
@@ -81,32 +82,42 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         NCCommunicationCommon.shared.setup(userAgent: userAgent)
         
         startTimerErrorNetworking()
-
+        
         // LOG
-        let levelLog = CCUtility.getLogLevel()
-        NCCommunicationCommon.shared.levelLog = levelLog
+        var levelLog = 0
         if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
             NCCommunicationCommon.shared.pathLog = pathDirectoryGroup
         }
-        NCCommunicationCommon.shared.copyLogToDocumentDirectory = true
-        if isSimulatorOrTestFlight {
-            NCCommunicationCommon.shared.writeLog("Start session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
+        
+        if NCBrandOptions.shared.disable_log {
+            
+            NCUtilityFileSystem.shared.deleteFile(filePath: NCCommunicationCommon.shared.filenamePathLog)
+            NCUtilityFileSystem.shared.deleteFile(filePath: NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! + "/" + NCCommunicationCommon.shared.filenameLog)
+            
         } else {
-            NCCommunicationCommon.shared.writeLog("Start session with level \(levelLog) " + versionNextcloudiOS)
+            
+            levelLog = CCUtility.getLogLevel()
+            NCCommunicationCommon.shared.levelLog = levelLog            
+            NCCommunicationCommon.shared.copyLogToDocumentDirectory = true
+            if isSimulatorOrTestFlight {
+                NCCommunicationCommon.shared.writeLog("Start session with level \(levelLog) " + versionNextcloudiOS + " (Simulator / TestFlight)")
+            } else {
+                NCCommunicationCommon.shared.writeLog("Start session with level \(levelLog) " + versionNextcloudiOS)
+            }
         }
         
         // Activate user account
-        if let resultActiveAccount = NCManageDatabase.shared.getAccountActive() {
+        if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
             
             // FIX 3.0.5 lost urlbase
-            if resultActiveAccount.urlBase.count == 0 {
-                let user = resultActiveAccount.user + " "
-                let urlBase = resultActiveAccount.account.replacingOccurrences(of: user, with: "")
-                resultActiveAccount.urlBase = urlBase
-                NCManageDatabase.shared.updateAccount(resultActiveAccount)
+            if activeAccount.urlBase.count == 0 {
+                let user = activeAccount.user + " "
+                let urlBase = activeAccount.account.replacingOccurrences(of: user, with: "")
+                activeAccount.urlBase = urlBase
+                NCManageDatabase.shared.updateAccount(activeAccount)
             }
             
-            settingAccount(resultActiveAccount.account, urlBase: resultActiveAccount.urlBase, user: resultActiveAccount.user, userId: resultActiveAccount.userId, password: CCUtility.getPassword(resultActiveAccount.account))
+            settingAccount(activeAccount.account, urlBase: activeAccount.urlBase, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account))
             
         } else {
             
@@ -116,9 +127,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             }
         }
         
-        // init home
-        NotificationCenter.default.addObserver(self, selector: #selector(initializeMain), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitializeMain), object: nil)
-        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+        // initialize
+        NotificationCenter.default.addObserver(self, selector: #selector(initialize), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterInitialize), object: nil)
+        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
         
         // Process upload
         networkingProcessUpload = NCNetworkingProcessUpload.init()
@@ -128,15 +139,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         UNUserNotificationCenter.current().delegate = self
         UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { (_, _) in }
 
-        // AV
+        // Audio Session
         do {
-            try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)
+            try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [.mixWithOthers, .allowAirPlay])
             try AVAudioSession.sharedInstance().setActive(true)
         } catch {
             print(error)
         }
-        application.beginReceivingRemoteControlEvents()
-                
+        
         // Store review
         if !NCUtility.shared.isSimulatorOrTestFlight() {
             let review = NCStoreReview()
@@ -144,17 +154,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             review.showStoreReview()
         }
         
-        // Detect Dark mode
-        if #available(iOS 13.0, *) {
-            if CCUtility.getDarkModeDetect() {
-                if UITraitCollection.current.userInterfaceStyle == .dark {
-                    CCUtility.setDarkMode(true)
-                } else {
-                    CCUtility.setDarkMode(false)
-                }
-            }
-        }
-        
         // Background task: register
         if #available(iOS 13.0, *) {
             BGTaskScheduler.shared.register(forTaskWithIdentifier: NCGlobal.shared.refreshTask, using: nil) { task in
@@ -200,7 +199,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         
         if account == "" { return }
 
-        NCNetworking.shared.verifyUploadZombie()
+        networkingProcessUpload?.verifyUploadZombie()
         
         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterApplicationDidBecomeActive)
     }
@@ -209,9 +208,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     func applicationWillEnterForeground(_ application: UIApplication) {
         
         if account == "" { return }
-
+        guard let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return }
+        
+        // Account changed ??
+        if activeAccount.account != account {
+            settingAccount(activeAccount.account, urlBase: activeAccount.urlBase, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account))
+            
+            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
+        }
+        
         NCCommunicationCommon.shared.writeLog("Application will enter in foreground")
         
+        // START TIMER UPLOAD PROCESS
+        if NCUtility.shared.isSimulator() {
+            networkingProcessUpload?.startTimer()
+        }
+        
         // Request Passcode
         passcodeWithAutomaticallyPromptForBiometricValidation(true)
         
@@ -247,6 +259,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         
         if account == "" { return }
         
+        // STOP TIMER UPLOAD PROCESS
+        if NCUtility.shared.isSimulator() {
+            networkingProcessUpload?.stopTimer()
+        }
+        
         NCCommunicationCommon.shared.writeLog("Application did enter in background")
         
         passcodeWithAutomaticallyPromptForBiometricValidation(false)
@@ -267,14 +284,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     
     // MARK: -
 
-    @objc func initializeMain() {
+    @objc func initialize() {
         
         if account == "" { return }
 
         NCCommunicationCommon.shared.writeLog("initialize Main")
         
         // Clear error certificate
-        CCUtility.setCertificateError(account, error: false)
+        CCUtility.clearCertificateError(account)
         
         // Registeration push notification
         NCPushNotification.shared().pushNotification()
@@ -511,6 +528,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
     }
     
+    func viewCertificateDetailsDismiss() {
+        self.startTimerErrorNetworking()
+    }
+    
     @objc func startTimerErrorNetworking() {
         timerErrorNetworking = Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(checkErrorNetworking), userInfo: nil, repeats: true)
     }
@@ -519,7 +540,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         
         if account == "" { return }
         
-        // check unauthorized server (401)
+        // check unauthorized server (401/403)
         if CCUtility.getPassword(account)!.count == 0 {
             openLogin(viewController: window?.rootViewController, selector: NCGlobal.shared.introLogin, openLoginWeb: true)
         }
@@ -530,7 +551,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             let alertController = UIAlertController(title: NSLocalizedString("_ssl_certificate_untrusted_", comment: ""), message: NSLocalizedString("_connect_server_anyway_", comment: ""), preferredStyle: .alert)
                         
             alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .default, handler: { action in
-                NCNetworking.shared.writeCertificate(directoryCertificate: CCUtility.getDirectoryCerificates())
+                NCNetworking.shared.writeCertificate(url: self.urlBase)
+                CCUtility.clearCertificateError(self.account)
                 self.startTimerErrorNetworking()
             }))
             
@@ -538,6 +560,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                 self.startTimerErrorNetworking()
             }))
             
+            alertController.addAction(UIAlertAction(title: NSLocalizedString("_certificate_details_", comment: ""), style: .default, handler: { action in
+                if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() as? UINavigationController {
+                    let viewController = navigationController.topViewController as! NCViewCertificateDetails
+                    viewController.delegate = self
+                    self.window?.rootViewController?.present(navigationController, animated: true)
+                }
+            }))
+            
             window?.rootViewController?.present(alertController, animated: true, completion: {
                 self.timerErrorNetworking?.invalidate()
             })
@@ -569,9 +599,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         
         if let account = NCManageDatabase.shared.getAccount(predicate: NSPredicate(format: "account == %@", account)) {
             NCPushNotification.shared().unsubscribingNextcloudServerPushNotification(account.account, urlBase: account.urlBase, user: account.user, withSubscribing: false)
-        }
-        
-        settingAccount("", urlBase: "", user: "", userId: "", password: "")
+        }        
         
         let results = NCManageDatabase.shared.getTableLocalFiles(predicate: NSPredicate(format: "account == %@", account), sorted: "ocId", ascending: false)
         for result in results {
@@ -581,16 +609,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         
         CCUtility.clearAllKeysEnd(toEnd: account)
         CCUtility.clearAllKeysPushNotification(account)
-        CCUtility.setCertificateError(account, error: false)
+        CCUtility.clearCertificateError(account)
         CCUtility.setPassword(account, password: nil)
         
         if wipe {
+            settingAccount("", urlBase: "", user: "", userId: "", password: "")
             let accounts = NCManageDatabase.shared.getAccounts()
             if accounts?.count ?? 0 > 0 {
                 if let newAccount = accounts?.first {
                     if let account = NCManageDatabase.shared.setAccountActive(newAccount) {
                         settingAccount(account.account, urlBase: account.urlBase, user: account.user, userId: account.userId, password: CCUtility.getPassword(account.account))
-                        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+                        NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
                     }
                 }
             } else {
@@ -599,8 +628,27 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
     }
     
+    @objc func changeAccount(_ account: String) {
+        
+        NCManageDatabase.shared.setAccountActive(account)
+        if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
+            
+            NCOperationQueue.shared.cancelAllQueue()
+            NCNetworking.shared.cancelAllTask()
+            
+            settingAccount(activeAccount.account, urlBase: activeAccount.urlBase, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account))
+            
+            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
+        }
+    }
+    
     // MARK: - Account Request
     
+    func accountRequestChangeAccount(account: String) {
+        
+        changeAccount(account)
+    }
+    
     func requestAccount(startTimer: Bool) {
               
         let accounts = NCManageDatabase.shared.getAllAccount()
@@ -609,16 +657,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
             
             if let vcAccountRequest = UIStoryboard(name: "NCAccountRequest", bundle: nil).instantiateInitialViewController() as? NCAccountRequest {
                
+                vcAccountRequest.activeAccount = NCManageDatabase.shared.getActiveAccount()
                 vcAccountRequest.accounts = accounts
                 vcAccountRequest.enableTimerProgress = true
                 vcAccountRequest.enableAddAccount = false
                 vcAccountRequest.dismissDidEnterBackground = false
+                vcAccountRequest.delegate = self
                 
                 let screenHeighMax = UIScreen.main.bounds.height - (UIScreen.main.bounds.height/5)
                 let numberCell = accounts.count
-                let height = min(CGFloat(numberCell * Int(vcAccountRequest.heightCell) + 65), screenHeighMax)
+                let height = min(CGFloat(numberCell * Int(vcAccountRequest.heightCell) + 45), screenHeighMax)
                 
-                let popup = NCPopupViewController(contentController: vcAccountRequest, popupWidth: 300, popupHeight: height)
+                let popup = NCPopupViewController(contentController: vcAccountRequest, popupWidth: 300, popupHeight: height+20)
                 popup.backgroundAlpha = 0.8
                 
                 UIApplication.shared.keyWindow?.rootViewController?.present(popup, animated: true)
@@ -649,12 +699,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
         
         if passcodeViewController == nil {
-            passcodeViewController = TOPasscodeViewController.init(style: .translucentLight, passcodeType: .sixDigits)
-            if #available(iOS 13.0, *) {
-                if UITraitCollection.current.userInterfaceStyle == .dark {
-                    passcodeViewController?.style = .translucentDark
-                }
-            }
+            passcodeViewController = TOPasscodeViewController.init(passcodeType: .sixDigits, allowCancel: false)
             passcodeViewController?.delegate = self
             passcodeViewController?.keypadButtonShowLettering = false
             if CCUtility.getEnableTouchFaceID() && laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
@@ -740,12 +785,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                 guard let pathScheme = CCUtility.value(forKey: "path", fromQueryItems: queryItems) else { return false }
                 guard let linkScheme = CCUtility.value(forKey: "link", fromQueryItems: queryItems) else { return false }
                 
-                if let account = NCManageDatabase.shared.getAccountActive() {
+                if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
                     
-                    let urlBase = URL(string: account.urlBase)
-                    let user = account.user
+                    let urlBase = URL(string: activeAccount.urlBase)
+                    let user = activeAccount.user
                     if linkScheme.contains(urlBase?.host ?? "") && userScheme == user {
-                        matchedAccount = account
+                        matchedAccount = activeAccount
                     } else {
                         let accounts = NCManageDatabase.shared.getAllAccount()
                         for account in accounts {
@@ -754,7 +799,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                                 NCManageDatabase.shared.setAccountActive(account.account)
                                 settingAccount(account.account, urlBase: account.urlBase, user: account.user, userId: account.userId, password: CCUtility.getPassword(account.account))
                                 matchedAccount = account
-                                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+                                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
                                 break
                             }
                         }
@@ -762,7 +807,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                     
                     if matchedAccount != nil {
                         
-                        let webDAV = NCUtilityFileSystem.shared.getWebDAV(account: account.account)
+                        let webDAV = NCUtilityFileSystem.shared.getWebDAV(account: activeAccount.account)
                         if pathScheme.contains("/") {
                             fileName = (pathScheme as NSString).lastPathComponent
                             serverUrl = matchedAccount!.urlBase + "/" + webDAV + "/" + (pathScheme as NSString).deletingLastPathComponent

+ 257 - 0
iOSClient/BackgroundImageColor/NCBackgroundImageColor.storyboard

@@ -0,0 +1,257 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="V0q-CP-xMJ">
+    <device id="retina3_5" orientation="portrait" appearance="light"/>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
+        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="System colors in document resources" minToolsVersion="11.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <scenes>
+        <!--Background Image Color-->
+        <scene sceneID="L90-uG-f4z">
+            <objects>
+                <viewController id="V0q-CP-xMJ" customClass="NCBackgroundImageColor" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="gzh-6E-hc4">
+                        <rect key="frame" x="0.0" y="0.0" width="300" height="450"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Background" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nZr-nE-ths">
+                                <rect key="frame" x="20" y="15" width="260" height="18"/>
+                                <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iU2-DL-ICv">
+                                <rect key="frame" x="0.0" y="53" width="300" height="250"/>
+                                <subviews>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3E4-fA-LuC">
+                                        <rect key="frame" x="260" y="0.0" width="30" height="30"/>
+                                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                        <constraints>
+                                            <constraint firstAttribute="width" constant="30" id="7gh-HI-7F4"/>
+                                            <constraint firstAttribute="height" constant="30" id="tN7-80-0OA"/>
+                                        </constraints>
+                                        <connections>
+                                            <action selector="whiteButtonAction:" destination="V0q-CP-xMJ" eventType="touchUpInside" id="qan-1S-lXZ"/>
+                                        </connections>
+                                    </button>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wje-qo-0av">
+                                        <rect key="frame" x="260" y="50" width="30" height="30"/>
+                                        <color key="backgroundColor" systemColor="systemOrangeColor"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="30" id="eEj-s3-RlJ"/>
+                                            <constraint firstAttribute="width" constant="30" id="wll-2m-eab"/>
+                                        </constraints>
+                                        <connections>
+                                            <action selector="orangeButtonAction:" destination="V0q-CP-xMJ" eventType="touchUpInside" id="rze-5I-h4O"/>
+                                        </connections>
+                                    </button>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aan-mm-3h8">
+                                        <rect key="frame" x="260" y="100" width="30" height="30"/>
+                                        <color key="backgroundColor" systemColor="systemRedColor"/>
+                                        <constraints>
+                                            <constraint firstAttribute="width" constant="30" id="KEh-Br-hec"/>
+                                            <constraint firstAttribute="height" constant="30" id="KF6-bC-uqI"/>
+                                        </constraints>
+                                        <connections>
+                                            <action selector="redButtonAction:" destination="V0q-CP-xMJ" eventType="touchUpInside" id="DQh-Gp-afZ"/>
+                                        </connections>
+                                    </button>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ele-7I-DxL">
+                                        <rect key="frame" x="260" y="150" width="30" height="30"/>
+                                        <color key="backgroundColor" systemColor="systemGreenColor"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="30" id="DgY-z7-3HB"/>
+                                            <constraint firstAttribute="width" constant="30" id="NZK-QF-30V"/>
+                                        </constraints>
+                                        <state key="normal">
+                                            <preferredSymbolConfiguration key="preferredSymbolConfiguration" scale="default"/>
+                                        </state>
+                                        <connections>
+                                            <action selector="greenButtonAction:" destination="V0q-CP-xMJ" eventType="touchUpInside" id="vz7-sI-OZN"/>
+                                        </connections>
+                                    </button>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="STo-4B-X2d">
+                                        <rect key="frame" x="260" y="200" width="30" height="30"/>
+                                        <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                        <constraints>
+                                            <constraint firstAttribute="width" constant="30" id="Qez-ew-4Ft"/>
+                                            <constraint firstAttribute="height" constant="30" id="bNc-qJ-yHL"/>
+                                        </constraints>
+                                        <state key="normal">
+                                            <preferredSymbolConfiguration key="preferredSymbolConfiguration" scale="default"/>
+                                        </state>
+                                        <connections>
+                                            <action selector="blackButtonAction:" destination="V0q-CP-xMJ" eventType="touchUpInside" id="FjW-KU-IXB"/>
+                                        </connections>
+                                    </button>
+                                </subviews>
+                                <constraints>
+                                    <constraint firstItem="STo-4B-X2d" firstAttribute="top" secondItem="ele-7I-DxL" secondAttribute="bottom" constant="20" id="BKq-hv-vnm"/>
+                                    <constraint firstAttribute="trailing" secondItem="ele-7I-DxL" secondAttribute="trailing" constant="10" id="FvE-ra-6MO"/>
+                                    <constraint firstAttribute="trailing" secondItem="STo-4B-X2d" secondAttribute="trailing" constant="10" id="H9y-WI-TXI"/>
+                                    <constraint firstAttribute="trailing" secondItem="3E4-fA-LuC" secondAttribute="trailing" constant="10" id="UoS-lh-xRi"/>
+                                    <constraint firstAttribute="trailing" secondItem="aan-mm-3h8" secondAttribute="trailing" constant="10" id="VKC-iZ-oKg"/>
+                                    <constraint firstItem="aan-mm-3h8" firstAttribute="top" secondItem="wje-qo-0av" secondAttribute="bottom" constant="20" id="Vtc-IV-iRF"/>
+                                    <constraint firstItem="3E4-fA-LuC" firstAttribute="top" secondItem="iU2-DL-ICv" secondAttribute="top" id="XPi-Om-9AW"/>
+                                    <constraint firstItem="ele-7I-DxL" firstAttribute="top" secondItem="aan-mm-3h8" secondAttribute="bottom" constant="20" id="ZFk-RV-bm7"/>
+                                    <constraint firstAttribute="trailing" secondItem="wje-qo-0av" secondAttribute="trailing" constant="10" id="au5-4T-kJG"/>
+                                    <constraint firstItem="wje-qo-0av" firstAttribute="top" secondItem="3E4-fA-LuC" secondAttribute="bottom" constant="20" id="p2S-Vf-mU1"/>
+                                    <constraint firstAttribute="height" constant="250" id="v0B-oB-eD3"/>
+                                </constraints>
+                            </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7CJ-Q0-ABH" userLabel="SeparatorV">
+                                <rect key="frame" x="150" y="400" width="0.5" height="50"/>
+                                <color key="backgroundColor" systemColor="systemGray4Color"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="0.5" id="wU1-tA-NZk"/>
+                                </constraints>
+                            </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ouH-gK-Guv" userLabel="SeparatorH">
+                                <rect key="frame" x="0.0" y="399.5" width="300" height="0.5"/>
+                                <color key="backgroundColor" systemColor="systemGray4Color"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="0.5" id="2OQ-Mt-Gnh"/>
+                                </constraints>
+                            </view>
+                            <button opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="249" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="W5y-aT-UlI">
+                                <rect key="frame" x="0.0" y="400" width="150" height="50"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="50" id="xnX-6W-gp9"/>
+                                </constraints>
+                                <fontDescription key="fontDescription" type="system" pointSize="16"/>
+                                <state key="normal" title="Cancel">
+                                    <color key="titleColor" systemColor="systemBlueColor"/>
+                                </state>
+                                <connections>
+                                    <action selector="cancelAction:" destination="V0q-CP-xMJ" eventType="touchUpInside" id="z5n-6l-qtR"/>
+                                </connections>
+                            </button>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hcV-V0-eZB">
+                                <rect key="frame" x="150" y="400" width="150" height="50"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="16"/>
+                                <state key="normal" title="Ok">
+                                    <color key="titleColor" systemColor="systemBlueColor"/>
+                                </state>
+                                <connections>
+                                    <action selector="okAction:" destination="V0q-CP-xMJ" eventType="touchUpInside" id="DO8-xB-WXf"/>
+                                </connections>
+                            </button>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Dsj-Of-TI5">
+                                <rect key="frame" x="0.0" y="308" width="300" height="80"/>
+                                <subviews>
+                                    <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qCH-0e-MgJ">
+                                        <rect key="frame" x="241" y="3.5" width="51" height="31"/>
+                                        <connections>
+                                            <action selector="darkmodeAction:" destination="V0q-CP-xMJ" eventType="valueChanged" id="jpD-6b-nRS"/>
+                                        </connections>
+                                    </switch>
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="dark mode" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AH4-ei-W3C">
+                                        <rect key="frame" x="10" y="10" width="221" height="18"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                                        <nil key="textColor"/>
+                                        <nil key="highlightedColor"/>
+                                    </label>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6Dy-77-TIC">
+                                        <rect key="frame" x="10" y="48" width="280" height="30"/>
+                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="30" id="ZKT-Su-3nU"/>
+                                        </constraints>
+                                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                                        <state key="normal" title="default color">
+                                            <color key="titleColor" systemColor="labelColor"/>
+                                        </state>
+                                        <connections>
+                                            <action selector="defaultAction:" destination="V0q-CP-xMJ" eventType="touchUpInside" id="iTy-8K-wVB"/>
+                                        </connections>
+                                    </button>
+                                </subviews>
+                                <constraints>
+                                    <constraint firstItem="6Dy-77-TIC" firstAttribute="top" secondItem="AH4-ei-W3C" secondAttribute="bottom" constant="20" id="0J5-Y3-Z2f"/>
+                                    <constraint firstItem="qCH-0e-MgJ" firstAttribute="centerY" secondItem="AH4-ei-W3C" secondAttribute="centerY" id="7pt-EI-Zgu"/>
+                                    <constraint firstItem="AH4-ei-W3C" firstAttribute="top" secondItem="Dsj-Of-TI5" secondAttribute="top" constant="10" id="9E5-Em-VG8"/>
+                                    <constraint firstItem="qCH-0e-MgJ" firstAttribute="leading" secondItem="AH4-ei-W3C" secondAttribute="trailing" constant="10" id="9qm-mi-Gwb"/>
+                                    <constraint firstItem="AH4-ei-W3C" firstAttribute="leading" secondItem="Dsj-Of-TI5" secondAttribute="leading" constant="10" id="Afp-ca-hx0"/>
+                                    <constraint firstItem="6Dy-77-TIC" firstAttribute="leading" secondItem="Dsj-Of-TI5" secondAttribute="leading" constant="10" id="Bn8-Bi-qOg"/>
+                                    <constraint firstAttribute="trailing" secondItem="qCH-0e-MgJ" secondAttribute="trailing" constant="10" id="QVc-0U-Mg8"/>
+                                    <constraint firstAttribute="trailing" secondItem="6Dy-77-TIC" secondAttribute="trailing" constant="10" id="jId-wH-r5I"/>
+                                    <constraint firstAttribute="height" constant="80" id="uSG-oG-ooi"/>
+                                </constraints>
+                            </view>
+                        </subviews>
+                        <viewLayoutGuide key="safeArea" id="1c1-7Q-WMG"/>
+                        <color key="backgroundColor" systemColor="systemGray6Color"/>
+                        <constraints>
+                            <constraint firstItem="hcV-V0-eZB" firstAttribute="top" secondItem="ouH-gK-Guv" secondAttribute="bottom" id="1MZ-1P-Ej1"/>
+                            <constraint firstItem="1c1-7Q-WMG" firstAttribute="bottom" secondItem="hcV-V0-eZB" secondAttribute="bottom" id="2Wh-Y6-n8F"/>
+                            <constraint firstItem="1c1-7Q-WMG" firstAttribute="trailing" secondItem="iU2-DL-ICv" secondAttribute="trailing" id="3Mn-1r-AGf"/>
+                            <constraint firstItem="Dsj-Of-TI5" firstAttribute="top" secondItem="iU2-DL-ICv" secondAttribute="bottom" constant="5" id="7kJ-dL-S5M"/>
+                            <constraint firstItem="1c1-7Q-WMG" firstAttribute="bottom" secondItem="7CJ-Q0-ABH" secondAttribute="bottom" id="8HO-F9-tfD"/>
+                            <constraint firstItem="ouH-gK-Guv" firstAttribute="leading" secondItem="1c1-7Q-WMG" secondAttribute="leading" id="A6T-ed-97T"/>
+                            <constraint firstItem="hcV-V0-eZB" firstAttribute="leading" secondItem="W5y-aT-UlI" secondAttribute="trailing" id="Aa4-Pg-Ioh"/>
+                            <constraint firstItem="1c1-7Q-WMG" firstAttribute="trailing" secondItem="nZr-nE-ths" secondAttribute="trailing" constant="20" id="DPW-MV-oKc"/>
+                            <constraint firstItem="7CJ-Q0-ABH" firstAttribute="centerX" secondItem="1c1-7Q-WMG" secondAttribute="centerX" id="EVx-ob-2bn"/>
+                            <constraint firstItem="nZr-nE-ths" firstAttribute="leading" secondItem="1c1-7Q-WMG" secondAttribute="leading" constant="20" id="SI9-xL-6s8"/>
+                            <constraint firstItem="iU2-DL-ICv" firstAttribute="top" secondItem="nZr-nE-ths" secondAttribute="bottom" constant="20" id="ZrF-wP-mwm"/>
+                            <constraint firstItem="iU2-DL-ICv" firstAttribute="leading" secondItem="1c1-7Q-WMG" secondAttribute="leading" id="aNT-a0-r8t"/>
+                            <constraint firstItem="1c1-7Q-WMG" firstAttribute="bottom" secondItem="W5y-aT-UlI" secondAttribute="bottom" id="ai8-AR-XYe"/>
+                            <constraint firstItem="7CJ-Q0-ABH" firstAttribute="top" secondItem="ouH-gK-Guv" secondAttribute="bottom" id="an1-EN-YiB"/>
+                            <constraint firstItem="1c1-7Q-WMG" firstAttribute="trailing" secondItem="W5y-aT-UlI" secondAttribute="trailing" multiplier="2" id="g0h-1g-A3R"/>
+                            <constraint firstItem="Dsj-Of-TI5" firstAttribute="leading" secondItem="1c1-7Q-WMG" secondAttribute="leading" id="gYm-lv-oVe"/>
+                            <constraint firstItem="1c1-7Q-WMG" firstAttribute="trailing" secondItem="hcV-V0-eZB" secondAttribute="trailing" id="heW-2p-hLJ"/>
+                            <constraint firstItem="W5y-aT-UlI" firstAttribute="leading" secondItem="1c1-7Q-WMG" secondAttribute="leading" id="kw6-l5-CAR"/>
+                            <constraint firstItem="nZr-nE-ths" firstAttribute="top" secondItem="1c1-7Q-WMG" secondAttribute="top" constant="15" id="oyJ-sj-j5N"/>
+                            <constraint firstItem="1c1-7Q-WMG" firstAttribute="trailing" secondItem="ouH-gK-Guv" secondAttribute="trailing" id="r1N-R6-iZg"/>
+                            <constraint firstItem="1c1-7Q-WMG" firstAttribute="trailing" secondItem="Dsj-Of-TI5" secondAttribute="trailing" id="tA5-3w-2U2"/>
+                            <constraint firstItem="W5y-aT-UlI" firstAttribute="top" secondItem="ouH-gK-Guv" secondAttribute="bottom" id="ywb-oW-pJe"/>
+                        </constraints>
+                    </view>
+                    <navigationItem key="navigationItem" id="Zon-2j-rsc"/>
+                    <size key="freeformSize" width="300" height="450"/>
+                    <connections>
+                        <outlet property="blackButton" destination="STo-4B-X2d" id="XwW-Q1-u9Y"/>
+                        <outlet property="cancelButton" destination="W5y-aT-UlI" id="P9l-o1-miU"/>
+                        <outlet property="chromaColorPickerView" destination="iU2-DL-ICv" id="iX8-Pq-EFB"/>
+                        <outlet property="darkmodeLabel" destination="AH4-ei-W3C" id="JvO-LN-BUu"/>
+                        <outlet property="darkmodeSwitch" destination="qCH-0e-MgJ" id="rjG-X5-eqA"/>
+                        <outlet property="defaultButton" destination="6Dy-77-TIC" id="PxM-tG-Ve7"/>
+                        <outlet property="greenButton" destination="ele-7I-DxL" id="vYB-cv-c6D"/>
+                        <outlet property="okButton" destination="hcV-V0-eZB" id="1VQ-qp-4Fs"/>
+                        <outlet property="orangeButton" destination="wje-qo-0av" id="LN8-3w-Wtx"/>
+                        <outlet property="redButton" destination="aan-mm-3h8" id="X89-dx-fGV"/>
+                        <outlet property="titleLabel" destination="nZr-nE-ths" id="UbA-Dl-0Ad"/>
+                        <outlet property="whiteButton" destination="3E4-fA-LuC" id="mNg-2f-rvs"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="qdm-Cl-C5l" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="1453.125" y="133.75"/>
+        </scene>
+    </scenes>
+    <resources>
+        <systemColor name="labelColor">
+            <color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
+        <systemColor name="systemBlueColor">
+            <color red="0.0" green="0.47843137254901963" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
+        <systemColor name="systemGray4Color">
+            <color red="0.81960784313725488" green="0.81960784313725488" blue="0.83921568627450982" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
+        <systemColor name="systemGray6Color">
+            <color red="0.94901960784313721" green="0.94901960784313721" blue="0.96862745098039216" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
+        <systemColor name="systemGreenColor">
+            <color red="0.20392156862745098" green="0.7803921568627451" blue="0.34901960784313724" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
+        <systemColor name="systemOrangeColor">
+            <color red="1" green="0.58431372549019611" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
+        <systemColor name="systemRedColor">
+            <color red="1" green="0.23137254901960785" blue="0.18823529411764706" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
+    </resources>
+</document>

+ 302 - 0
iOSClient/BackgroundImageColor/NCBackgroundImageColor.swift

@@ -0,0 +1,302 @@
+//
+//  NCBackgroundImageColor.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 05/05/21.
+//  Copyright © 2021 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  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
+import ChromaColorPicker
+
+public protocol NCBackgroundImageColorDelegate {
+    func colorPickerCancel()
+    func colorPickerWillChange(color: UIColor)
+    func colorPickerDidChange(lightColor: String, darkColor: String)
+}
+
+// optional func
+public extension NCBackgroundImageColorDelegate {
+    func colorPickerCancel() {}
+    func colorPickerWillChange(color: UIColor) { }
+    func colorPickerDidChange(lightColor: String, darkColor: String) { }
+}
+
+class NCBackgroundImageColor: UIViewController {
+
+    @IBOutlet weak var titleLabel: UILabel!
+    @IBOutlet weak var chromaColorPickerView: UIView!
+    
+    @IBOutlet weak var whiteButton: UIButton!
+    @IBOutlet weak var orangeButton: UIButton!
+    @IBOutlet weak var redButton: UIButton!
+    @IBOutlet weak var greenButton: UIButton!
+    @IBOutlet weak var blackButton: UIButton!
+
+    @IBOutlet weak var darkmodeLabel: UILabel!
+    @IBOutlet weak var darkmodeSwitch: UISwitch!
+    
+    @IBOutlet weak var defaultButton: UIButton!
+    @IBOutlet weak var cancelButton: UIButton!
+    @IBOutlet weak var okButton: UIButton!
+    
+    private let colorPicker = ChromaColorPicker()
+    private let brightnessSlider = ChromaBrightnessSlider()
+    private var colorHandle: ChromaColorHandle?
+    private let defaultColorPickerSize = CGSize(width: 200, height: 200)
+    private let brightnessSliderWidthHeightRatio: CGFloat = 0.1
+    
+    var delegate: NCBackgroundImageColorDelegate?
+    var setupColor: UIColor?
+    var darkColor = "#000000"
+    var lightColor = "#FFFFFF"
+    
+    let width: CGFloat = 300
+    let height: CGFloat = 450
+    
+    // MARK: - View Life Cycle
+
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        
+        setupColorPicker()
+        setupBrightnessSlider()
+        setupColorPickerHandles()
+        
+        titleLabel.text = NSLocalizedString("_background_", comment: "")
+        darkmodeLabel.text = NSLocalizedString("_dark_mode_", comment: "")
+
+        defaultButton.setTitle(NSLocalizedString("_default_color_", comment: ""), for: .normal)
+
+        cancelButton.setTitle(NSLocalizedString("_cancel_", comment: ""), for: .normal)
+        okButton.setTitle(NSLocalizedString("_ok_", comment: ""), for: .normal)
+        
+        whiteButton.backgroundColor = .white
+        whiteButton.layer.cornerRadius = 5
+        whiteButton.layer.borderWidth = 0.5
+        whiteButton.layer.borderColor = NCBrandColor.shared.label.cgColor
+        whiteButton.layer.masksToBounds = true
+
+        orangeButton.backgroundColor = .orange
+        orangeButton.layer.cornerRadius = 5
+        orangeButton.layer.borderWidth = 0.5
+        orangeButton.layer.borderColor = NCBrandColor.shared.label.cgColor
+        orangeButton.layer.masksToBounds = true
+       
+        redButton.backgroundColor = .red
+        redButton.layer.cornerRadius = 5
+        redButton.layer.borderWidth = 0.5
+        redButton.layer.borderColor = NCBrandColor.shared.label.cgColor
+        redButton.layer.masksToBounds = true
+        
+        greenButton.backgroundColor = .green
+        greenButton.layer.cornerRadius = 5
+        greenButton.layer.borderWidth = 0.5
+        greenButton.layer.borderColor = NCBrandColor.shared.label.cgColor
+        greenButton.layer.masksToBounds = true
+        
+        blackButton.backgroundColor = .black
+        blackButton.layer.cornerRadius = 5
+        blackButton.layer.borderWidth = 0.5
+        blackButton.layer.borderColor = NCBrandColor.shared.label.cgColor
+        blackButton.layer.masksToBounds = true
+        
+        defaultButton.layer.cornerRadius = 15
+        defaultButton.layer.borderWidth = 0.5
+        defaultButton.layer.borderColor = UIColor.gray.cgColor
+        defaultButton.layer.masksToBounds = true
+    }
+    
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        
+        if traitCollection.userInterfaceStyle == .dark {
+            darkmodeSwitch.isOn = true
+        } else {
+            darkmodeSwitch.isOn = false
+        }
+
+        // Color for all folders
+        if let activeAccount = NCManageDatabase.shared.getActiveAccount() {
+            if darkColor == "" {
+                darkColor = activeAccount.darkColorBackground
+            }
+            if lightColor == "" {
+                lightColor = activeAccount.lightColorBackground
+            }
+        }
+       
+        // set color
+        if darkmodeSwitch.isOn {
+            if let color = UIColor.init(hex: darkColor) {
+                changeColor(color)
+            } else {
+                changeColor(.black)
+            }
+        } else {
+            if let color = UIColor.init(hex: lightColor) {
+                changeColor(color)
+            } else {
+                changeColor(.white)
+            }
+        }
+    }
+    
+    override func viewDidAppear(_ animated: Bool) {
+        super.viewDidAppear(animated)
+    }
+    
+    // MARK: - Action
+    
+    @IBAction func whiteButtonAction(_ sender: UIButton) {
+        changeColor(.white)
+    }
+    
+    @IBAction func orangeButtonAction(_ sender: UIButton) {
+        changeColor(.orange)
+    }
+    
+    @IBAction func redButtonAction(_ sender: UIButton) {
+        changeColor(.red)
+    }
+    
+    @IBAction func greenButtonAction(_ sender: UIButton) {
+        changeColor(.green)
+    }
+    
+    @IBAction func blackButtonAction(_ sender: UIButton) {
+        changeColor(.black)
+    }
+    
+    @IBAction func darkmodeAction(_ sender: UISwitch) {
+                
+        if sender.isOn {
+            if darkColor == "" {
+                changeColor(.black)
+            } else {
+                if let color = UIColor.init(hex: darkColor) {
+                    changeColor(color)
+                }
+            }
+        } else {
+            if lightColor == "" {
+                changeColor(.white)
+            } else {
+                if let color = UIColor.init(hex: lightColor) {
+                    changeColor(color)
+                }
+            }
+        }
+    }
+    
+    @IBAction func defaultAction(_ sender: Any) {
+        
+        if darkmodeSwitch.isOn {
+            darkColor = "#000000"
+            changeColor(.black)
+        } else {
+            lightColor = "#FFFFFF"
+            changeColor(.white)
+        }
+    }
+    
+    @IBAction func cancelAction(_ sender: Any) {
+
+        self.delegate?.colorPickerCancel()
+        dismiss(animated: true)
+    }
+    
+    @IBAction func okAction(_ sender: Any) {
+        
+        var lightColor = self.lightColor
+        var darkColor = self.darkColor
+        
+        if lightColor == "#FFFFFF" { lightColor = "" }
+        if darkColor == "#000000" { darkColor = "" }
+        
+        self.delegate?.colorPickerDidChange(lightColor: lightColor, darkColor: darkColor)
+        
+        dismiss(animated: true)
+    }
+    
+    // MARK: - ChromaColorPicker
+    
+    private func setupColorPicker() {
+        colorPicker.delegate = self
+        colorPicker.translatesAutoresizingMaskIntoConstraints = false
+        view.addSubview(colorPicker)
+
+        NSLayoutConstraint.activate([
+            colorPicker.leadingAnchor.constraint(equalTo: chromaColorPickerView.leadingAnchor, constant: 20),
+            colorPicker.topAnchor.constraint(equalTo: chromaColorPickerView.topAnchor),
+            colorPicker.widthAnchor.constraint(equalToConstant: defaultColorPickerSize.width),
+            colorPicker.heightAnchor.constraint(equalToConstant: defaultColorPickerSize.height)
+        ])
+    }
+    
+    private func setupBrightnessSlider() {
+        brightnessSlider.connect(to: colorPicker)
+        
+        // Style
+        brightnessSlider.trackColor = UIColor.blue
+        brightnessSlider.handle.borderWidth = 3.0 // Example of customizing the handle's properties.
+        
+        // Layout
+        brightnessSlider.translatesAutoresizingMaskIntoConstraints = false
+        view.addSubview(brightnessSlider)
+        
+        NSLayoutConstraint.activate([
+            brightnessSlider.centerXAnchor.constraint(equalTo: colorPicker.centerXAnchor),
+            brightnessSlider.topAnchor.constraint(equalTo: colorPicker.bottomAnchor, constant: 20),
+            brightnessSlider.widthAnchor.constraint(equalTo: colorPicker.widthAnchor, multiplier: 1),
+            brightnessSlider.heightAnchor.constraint(equalTo: brightnessSlider.widthAnchor, multiplier: brightnessSliderWidthHeightRatio)
+        ])
+    }
+    
+    private func setupColorPickerHandles() {
+        colorHandle = colorPicker.addHandle(at: setupColor)
+    }
+    
+    private func changeColor(_ color: UIColor) {
+        
+        colorHandle?.color = color
+        colorPicker.setNeedsLayout()
+        brightnessSlider.trackColor = color
+        
+        if darkmodeSwitch.isOn {
+            darkColor = color.hexString
+        } else {
+            lightColor = color.hexString
+        }
+        
+        self.delegate?.colorPickerWillChange(color: color)
+    }
+}
+
+extension NCBackgroundImageColor: ChromaColorPickerDelegate {
+    func colorPickerHandleDidChange(_ colorPicker: ChromaColorPicker, handle: ChromaColorHandle, to color: UIColor) {
+        
+        if darkmodeSwitch.isOn {
+            darkColor = color.hexString
+        } else {
+            lightColor = color.hexString
+        }
+        
+        self.delegate?.colorPickerWillChange(color: color)
+    }
+}

+ 6 - 0
iOSClient/Brand/Background.xcassets/Contents.json

@@ -0,0 +1,6 @@
+{
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 0 - 1
iOSClient/Brand/Intro/NCIntroCollectionViewCell.swift

@@ -23,7 +23,6 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-
 import UIKit
 
 class NCIntroCollectionViewCell: UICollectionViewCell {

+ 3 - 1
iOSClient/Brand/Intro/NCIntroViewController.swift

@@ -41,6 +41,8 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
     private var textColor: UIColor = .white
     private var textColorOpponent: UIColor = .black
     
+    // MARK: - View Life Cycle
+
     override func viewDidLoad() {
         super.viewDidLoad()
         
@@ -75,7 +77,7 @@ class NCIntroViewController: UIViewController, UICollectionViewDataSource, UICol
 
         
         self.pageControl.currentPageIndicatorTintColor = textColor
-        self.pageControl.pageIndicatorTintColor = NCBrandColor.shared.nextcloudSoft
+        self.pageControl.pageIndicatorTintColor = .lightGray
 
         self.buttonLogin.layer.cornerRadius = 20
         self.buttonLogin.setTitleColor(textColorOpponent, for: .normal)

+ 179 - 55
iOSClient/Brand/NCBrand.swift

@@ -46,15 +46,17 @@ import UIKit
     }()
     
     @objc public var brand:                             String = "Nextcloud"
-    @objc public var mailMe:                            String = "ios@nextcloud.com"
-    @objc public var textCopyrightNextcloudiOS:         String = "Nextcloud Coherence for iOS %@ © 2021"
+    //@objc public var mailMe:                            String = "ios@nextcloud.com"                              // Deprecated
+    @objc public var textCopyrightNextcloudiOS:         String = "Nextcloud Liquid for iOS %@ © 2021"
     @objc public var textCopyrightNextcloudServer:      String = "Nextcloud Server %@"
     @objc public var loginBaseUrl:                      String = "https://cloud.nextcloud.com"
     @objc public var pushNotificationServerProxy:       String = "https://push-notifications.nextcloud.com"
     @objc public var linkLoginHost:                     String = "https://nextcloud.com/install"
     @objc public var linkloginPreferredProviders:       String = "https://nextcloud.com/signup-ios";
     @objc public var webLoginAutenticationProtocol:     String = "nc://"                                            // example "abc://"
-    
+    @objc public var privacy:                           String = "https://nextcloud.com/privacy"
+    @objc public var sourceCode:                        String = "https://github.com/nextcloud/ios"
+
     // Personalized
     @objc public var webCloseViewProtocolPersonalized:  String = ""                                                 // example "abc://change/plan"      Don't touch me !!
     @objc public var folderBrandAutoUpload:             String = ""                                                 // example "_auto_upload_folder_"   Don't touch me !!
@@ -86,6 +88,10 @@ import UIKit
     @objc public var disable_openin_file:               Bool = false                                                // Don't touch me !!
     @objc public var disable_crash_service:             Bool = false
     @objc public var disable_request_account:           Bool = false
+    @objc public var disable_log:                       Bool = false
+
+    @objc public var disable_background_color:          Bool = true
+    @objc public var disable_background_image:          Bool = true
 
     override init() {
         
@@ -100,7 +106,6 @@ import UIKit
 class NCBrandColor: NSObject {
     @objc static let shared: NCBrandColor = {
         let instance = NCBrandColor()
-        instance.setDarkMode()
         instance.createImagesThemingColor()
         return instance
     }()
@@ -131,6 +136,7 @@ class NCBrandColor: NSObject {
         
         static var buttonMore = UIImage()
         static var buttonStop = UIImage()
+        static var buttonRestore = UIImage()
     }
 
     // Color
@@ -140,41 +146,181 @@ class NCBrandColor: NSObject {
     @objc public var brand:                 UIColor                                                                                 // don't touch me
     @objc public var brandElement:          UIColor                                                                                 // don't touch me
     @objc public var brandText:             UIColor                                                                                 // don't touch me
-
-    @objc public var connectionNo:          UIColor = UIColor(red: 204.0/255.0, green: 204.0/255.0, blue: 204.0/255.0, alpha: 1.0)
-    @objc public var encrypted:             UIColor = .red
-    @objc public var backgroundView:        UIColor = .white
-    @objc public var backgroundForm:        UIColor = UIColor(red: 244.0/255.0, green: 244.0/255.0, blue: 244.0/255.0, alpha: 1.0)
-    @objc public var textView:              UIColor = .black
-    @objc public var separator:             UIColor = UIColor(red: 235.0/255.0, green: 235.0/255.0, blue: 235.0/255.0, alpha: 1.0)
-    @objc public var tabBar:                UIColor = .white
+    
     @objc public let nextcloud:             UIColor = UIColor(red: 0.0/255.0, green: 130.0/255.0, blue: 201.0/255.0, alpha: 1.0)
-    @objc public let nextcloudSoft:         UIColor = UIColor(red: 90.0/255.0, green: 160.0/255.0, blue: 210.0/255.0, alpha: 1.0)
-    @objc public let icon:                  UIColor = UIColor(red: 104.0/255.0, green: 104.0/255.0, blue: 104.0/255.0, alpha: 1.0)
-    @objc public let optionItem:            UIColor = UIColor(red: 178.0/255.0, green: 178.0/255.0, blue: 178.0/255.0, alpha: 1.0)
-    @objc public let graySoft:              UIColor = UIColor(red: 162.0/255.0, green: 162.0/255.0, blue: 162.0/255.0, alpha: 0.5)
+    @objc public let gray:                  UIColor = UIColor(red: 104.0/255.0, green: 104.0/255.0, blue: 104.0/255.0, alpha: 1.0)
+    @objc public let lightGray:             UIColor = UIColor(red: 229.0/255.0, green: 229.0/229.0, blue: 104.0/255.0, alpha: 1.0)
     @objc public let yellowFavorite:        UIColor = UIColor(red: 248.0/255.0, green: 205.0/255.0, blue: 70.0/255.0, alpha: 1.0)
-    @objc public let textInfo:              UIColor = UIColor(red: 153.0/255.0, green: 153.0/255.0, blue: 153.0/255.0, alpha: 1.0)
-    @objc public var select:                UIColor = .white
-    @objc public var avatarBorder:          UIColor = .white
 
+    @objc public var systemBackground: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .systemBackground
+            } else {
+                return .white
+            }
+        }
+    }
+    
+    @objc public var secondarySystemBackground: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .secondarySystemBackground
+            } else {
+                return UIColor(red: 0.95, green: 0.95, blue: 0.97, alpha: 1.0)
+            }
+        }
+    }
+    
+    @objc public var tertiarySystemBackground: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .tertiarySystemBackground
+            } else {
+                return UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
+            }
+        }
+    }
+    
+    @objc public var systemGroupedBackground: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .systemGroupedBackground
+            } else {
+                return UIColor(red: 0.95, green: 0.95, blue: 0.97, alpha: 1.0)
+            }
+        }
+    }
+    
+    @objc public var secondarySystemGroupedBackground: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .secondarySystemGroupedBackground
+            } else {
+                return .white
+            }
+        }
+    }
+    
+    @objc public var label: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .label
+            } else {
+                return .black
+            }
+        }
+    }
+    
+    @objc public var separator: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .separator
+            } else {
+                return UIColor(red: 0.24, green: 0.24, blue: 0.26, alpha: 1.0)
+            }
+        }
+    }
+    
+    @objc public var opaqueSeparator: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .opaqueSeparator
+            } else {
+                return UIColor(red: 0.78, green: 0.78, blue: 0.78, alpha: 1.0)
+            }
+        }
+    }
+    
+    @objc public var systemGray: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .systemGray
+            } else {
+                return UIColor(red: 0.56, green: 0.56, blue: 0.58, alpha: 1.0)
+            }
+        }
+    }
+    
+    @objc public var systemGray2: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .systemGray2
+            } else {
+                return UIColor(red: 0.68, green: 0.68, blue: 0.7, alpha: 1.0)
+            }
+        }
+    }
+    
+    @objc public var systemGray3: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .systemGray3
+            } else {
+                return UIColor(red: 0.78, green: 0.78, blue: 0.8, alpha: 1.0)
+            }
+        }
+    }
+    
+    @objc public var systemGray4: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .systemGray4
+            } else {
+                return UIColor(red: 0.82, green: 0.82, blue: 0.84, alpha: 1.0)
+            }
+        }
+    }
+    
+    @objc public var systemGray5: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .systemGray5
+            } else {
+                return UIColor(red: 0.9, green: 0.9, blue: 0.92, alpha: 1.0)
+            }
+        }
+    }
+    
+    @objc public var systemGray6: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .systemGray6
+            } else {
+                return UIColor(red: 0.95, green: 0.95, blue: 0.97, alpha: 1.0)
+            }
+        }
+    }
+    
+    @objc public var systemFill: UIColor {
+        get {
+            if #available(iOS 13, *) {
+                return .systemFill
+            } else {
+                return UIColor(red: 120/255, green: 120/255, blue: 120/255, alpha: 1.0)
+            }
+        }
+    }
+    
     override init() {
         self.brand = self.customer
         self.brandElement = self.customer
         self.brandText = self.customerText        
     }
     
-    private func createImagesThemingColor() {
+    public func createImagesThemingColor() {
         
+        let gray: UIColor = UIColor(red: 162.0/255.0, green: 162.0/255.0, blue: 162.0/255.0, alpha: 0.5)
+
         cacheImages.file = UIImage.init(named: "file")!
         
-        cacheImages.shared = UIImage(named: "share")!.image(color: graySoft, size: 50)
-        cacheImages.canShare = UIImage(named: "share")!.image(color: graySoft, size: 50)
-        cacheImages.shareByLink = UIImage(named: "sharebylink")!.image(color: graySoft, size: 50)
+        cacheImages.shared = UIImage(named: "share")!.image(color: gray, size: 50)
+        cacheImages.canShare = UIImage(named: "share")!.image(color: gray, size: 50)
+        cacheImages.shareByLink = UIImage(named: "sharebylink")!.image(color: gray, size: 50)
         
         cacheImages.favorite = NCUtility.shared.loadImage(named: "star.fill", color: yellowFavorite)
-        cacheImages.comment = UIImage(named: "comment")!.image(color: graySoft, size: 50)
-        cacheImages.livePhoto = NCUtility.shared.loadImage(named: "livephoto", color: textView)
+        cacheImages.comment = UIImage(named: "comment")!.image(color: gray, size: 50)
+        cacheImages.livePhoto = NCUtility.shared.loadImage(named: "livephoto", color: label)
         cacheImages.offlineFlag = UIImage.init(named: "offlineFlag")!
         cacheImages.local = UIImage.init(named: "local")!
             
@@ -187,35 +333,15 @@ class NCBrandColor: NSObject {
         cacheImages.folderAutomaticUpload = UIImage(named: "folderAutomaticUpload")!.image(color: brandElement, size: folderWidth)
         cacheImages.folder =  UIImage(named: "folder")!.image(color: brandElement, size: folderWidth)
         
-        cacheImages.checkedYes = NCUtility.shared.loadImage(named: "checkmark.circle.fill", color: .darkGray)
-        cacheImages.checkedNo = NCUtility.shared.loadImage(named: "circle", color: graySoft)
+        cacheImages.checkedYes = NCUtility.shared.loadImage(named: "checkmark.circle.fill", color: .systemBlue)
+        cacheImages.checkedNo = NCUtility.shared.loadImage(named: "circle", color: gray)
         
-        cacheImages.buttonMore = UIImage(named: "more")!.image(color: graySoft, size: 50)
-        cacheImages.buttonStop = UIImage(named: "stop")!.image(color: graySoft, size: 50)
+        cacheImages.buttonMore = UIImage(named: "more")!.image(color: gray, size: 50)
+        cacheImages.buttonStop = UIImage(named: "stop")!.image(color: gray, size: 50)
+        cacheImages.buttonRestore = UIImage(named: "restore")!.image(color: gray, size: 50)
     }
     
-    @objc public func setDarkMode() {
-        let darkMode = CCUtility.getDarkMode()
-        if darkMode {
-            tabBar = UIColor(red: 25.0/255.0, green: 25.0/255.0, blue: 25.0/255.0, alpha: 1.0)
-            backgroundView = .black
-            backgroundForm = UIColor(red: 32.0/255.0, green: 32.0/255.0, blue: 32.0/255.0, alpha: 1.0)
-            textView = .white
-            separator = UIColor(red: 60.0/255.0, green: 60.0/255.0, blue: 60.0/255.0, alpha: 1.0)
-            select = UIColor.white.withAlphaComponent(0.2)
-            avatarBorder = .black
-        } else {
-            tabBar = .white
-            backgroundView = .white
-            backgroundForm = UIColor(red: 242.0/255.0, green: 242.0/255.0, blue: 242.0/255.0, alpha: 1.0)
-            textView = .black
-            separator = UIColor(red: 235.0/255.0, green: 235.0/255.0, blue: 235.0/255.0, alpha: 1.0)
-            select = self.brandElement.withAlphaComponent(0.1)
-            avatarBorder = .white
-        }
-    }
-    
-#if !EXTENSION
+    #if !EXTENSION
     public func settingThemingColor(account: String) {
         
         let darker: CGFloat = 30    // %
@@ -258,15 +384,13 @@ class NCBrandColor: NSObject {
             NCBrandColor.shared.brand = NCBrandColor.shared.customer
             NCBrandColor.shared.brandText = NCBrandColor.shared.customerText
         }
-        
-        setDarkMode()
-        
+                
         DispatchQueue.main.async {
             self.createImagesThemingColor()
             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterChangeTheming)
         }
     }
-#endif
+    #endif
     
     @objc func settingBrandColor(_ themingColor: String?, themingColorElement: String?, themingColorText: String?) {
                 

+ 6 - 6
iOSClient/BrowserWeb/NCBrowserWeb.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="OOi-qQ-BCK">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="OOi-qQ-BCK">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -17,12 +17,12 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Lht-2f-Ep4">
-                                <rect key="frame" x="374" y="54" width="30" height="30"/>
+                                <rect key="frame" x="10" y="54" width="30" height="30"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="30" id="ckh-Eb-Ze8"/>
                                     <constraint firstAttribute="width" constant="30" id="oHS-Ba-9eq"/>
                                 </constraints>
-                                <state key="normal" image="exitCircle"/>
+                                <state key="normal" image="exit"/>
                                 <connections>
                                     <action selector="touchUpInsideButtonExit:" destination="OOi-qQ-BCK" eventType="touchUpInside" id="hcA-Hb-TJd"/>
                                 </connections>
@@ -31,8 +31,8 @@
                         <viewLayoutGuide key="safeArea" id="fTU-bd-6qR"/>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <constraints>
+                            <constraint firstItem="Lht-2f-Ep4" firstAttribute="leading" secondItem="fTU-bd-6qR" secondAttribute="leading" constant="10" id="Oui-0m-UD8"/>
                             <constraint firstItem="Lht-2f-Ep4" firstAttribute="top" secondItem="fTU-bd-6qR" secondAttribute="top" constant="10" id="Qy7-ho-gnO"/>
-                            <constraint firstItem="fTU-bd-6qR" firstAttribute="trailing" secondItem="Lht-2f-Ep4" secondAttribute="trailing" constant="10" id="brR-Ag-YH0"/>
                         </constraints>
                     </view>
                     <connections>
@@ -45,6 +45,6 @@
         </scene>
     </scenes>
     <resources>
-        <image name="exitCircle" width="329" height="329"/>
+        <image name="exit" width="300" height="300"/>
     </resources>
 </document>

+ 5 - 2
iOSClient/BrowserWeb/NCBrowserWeb.swift

@@ -21,7 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 import WebKit
 
 @objc protocol NCBrowserWebDelegate: AnyObject {
@@ -40,6 +40,8 @@ class NCBrowserWeb: UIViewController {
     
     @IBOutlet weak var buttonExit: UIButton!
     
+    // MARK: - View Life Cycle
+
     override func viewDidLoad() {
         super.viewDidLoad()
         
@@ -57,6 +59,8 @@ class NCBrowserWeb: UIViewController {
             buttonExit.isHidden = true
         } else {
             self.view.bringSubviewToFront(buttonExit)
+            let image = NCUtility.shared.loadImage(named: "xmark", color: .systemBlue)
+            buttonExit.setImage(image, for: .normal)
         }
         
         loadWebPage(webView: webView!, url: URL(string: urlBase)!)
@@ -91,7 +95,6 @@ class NCBrowserWeb: UIViewController {
 
 extension NCBrowserWeb: WKNavigationDelegate {
     
-   
     public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
         if let serverTrust = challenge.protectionSpace.serverTrust {
             completionHandler(Foundation.URLSession.AuthChallengeDisposition.useCredential, URLCredential(trust: serverTrust))

+ 7 - 7
iOSClient/Data/NCDataSource.swift

@@ -21,7 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 
 class NCDataSource: NSObject {
     
@@ -39,14 +39,14 @@ class NCDataSource: NSObject {
         super.init()
     }
     
-    init(metadatasSource: [tableMetadata], sort: String = "", ascending: Bool = false, directoryOnTop: Bool = false, favoriteOnTop: Bool = false, filterLivePhoto: Bool = false) {
+    init(metadatasSource: [tableMetadata], sort: String? = "none", ascending: Bool? = false, directoryOnTop: Bool? = true, favoriteOnTop: Bool? = true, filterLivePhoto: Bool? = true) {
         super.init()
         
-        self.sort = sort
-        self.ascending = ascending
-        self.directoryOnTop = directoryOnTop
-        self.favoriteOnTop = favoriteOnTop
-        self.filterLivePhoto = filterLivePhoto
+        self.sort = sort ?? "none"
+        self.ascending = ascending ?? false
+        self.directoryOnTop = directoryOnTop ?? true
+        self.favoriteOnTop = favoriteOnTop ?? true
+        self.filterLivePhoto = filterLivePhoto ?? true
         
         createMetadatas(metadatasSource: metadatasSource)
     }

+ 20 - 1
iOSClient/Data/NCDatabase.swift

@@ -21,6 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+import UIKit
 import RealmSwift
 
 class tableAccount: Object {
@@ -79,6 +80,11 @@ class tableAccount: Object {
     @objc dynamic var userStatusStatusIsUserDefined: Bool = false
     @objc dynamic var webpage = ""
     @objc dynamic var zip = ""
+    
+    // COLOR Files
+    @objc dynamic var darkColorBackground = ""
+    @objc dynamic var lightColorBackground = ""
+
     // HC
     @objc dynamic var hcIsTrial: Bool = false
     @objc dynamic var hcTrialExpired: Bool = false
@@ -128,6 +134,7 @@ class tableActivity: Object {
 class tableActivityPreview: Object {
     
     @objc dynamic var account = ""
+    @objc dynamic var filename = ""
     @objc dynamic var idPrimaryKey = ""
     @objc dynamic var idActivity: Int = 0
     @objc dynamic var source = ""
@@ -169,6 +176,19 @@ class tableCapabilities: Object {
     }
 }
 
+class tableChunk: Object {
+    
+    @objc dynamic var account = ""
+    @objc dynamic var chunkFolder = ""
+    @objc dynamic var fileName = ""
+    @objc dynamic var index = ""
+    @objc dynamic var ocId = ""
+
+    override static func primaryKey() -> String {
+        return "index"
+    }
+}
+
 class tableComments: Object {
     
     @objc dynamic var account = ""
@@ -307,7 +327,6 @@ class tableMetadata: Object {
     @objc dynamic var account = ""
     @objc dynamic var assetLocalIdentifier = ""
     @objc dynamic var chunk: Bool = false
-    @objc dynamic var chunkFolder = ""
     @objc dynamic var commentsUnread: Bool = false
     @objc dynamic var contentType = ""
     @objc dynamic var creationDate = NSDate()

+ 1 - 1
iOSClient/Data/NCElementsJSON.swift

@@ -21,7 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 
 @objc class NCElementsJSON: NSObject {
     @objc static let shared: NCElementsJSON = {

+ 135 - 32
iOSClient/Data/NCManageDatabase.swift

@@ -21,6 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+import UIKit
 import RealmSwift
 import NCCommunication
 import SwiftyJSON
@@ -47,7 +48,7 @@ class NCManageDatabase: NSObject {
             let config = Realm.Configuration(
                 fileURL: dirGroup?.appendingPathComponent(NCGlobal.shared.appDatabaseNextcloud + "/" + NCGlobal.shared.databaseDefault),
                 schemaVersion: NCGlobal.shared.databaseSchemaVersion,
-                objectTypes: [tableMetadata.self, tableLocalFile.self, tableDirectory.self, tableTag.self, tableAccount.self, tableCapabilities.self, tableE2eEncryption.self]
+                objectTypes: [tableMetadata.self, tableLocalFile.self, tableDirectory.self, tableTag.self, tableAccount.self, tableCapabilities.self, tableE2eEncryption.self, tableE2eEncryptionLock.self, tableShare.self, tableChunk.self]
             )
             
             Realm.Configuration.defaultConfiguration = config
@@ -148,7 +149,7 @@ class NCManageDatabase: NSObject {
                 if let databaseFilePath = databaseFilePath {
                     do {
                         #if !EXTENSION
-                        NCContentPresenter.shared.messageNotification("_error_", description: "_database_corrupt_", delay: NCGlobal.shared.dismissAfterSecondLong, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.ErrorInternalError, forced: true)
+                        NCContentPresenter.shared.messageNotification("_error_", description: "_database_corrupt_", delay: NCGlobal.shared.dismissAfterSecondLong, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorInternalError, forced: true)
                         #endif
                         try FileManager.default.removeItem(at: databaseFilePath)
                     } catch {}
@@ -170,7 +171,7 @@ class NCManageDatabase: NSObject {
             if let databaseFilePath = databaseFilePath {
                 do {
                     #if !EXTENSION
-                    NCContentPresenter.shared.messageNotification("_error_", description: "_database_corrupt_", delay: NCGlobal.shared.dismissAfterSecondLong, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.ErrorInternalError, forced: true)
+                    NCContentPresenter.shared.messageNotification("_error_", description: "_database_corrupt_", delay: NCGlobal.shared.dismissAfterSecondLong, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorInternalError, forced: true)
                     #endif
                     try FileManager.default.removeItem(at: databaseFilePath)
                 } catch {}
@@ -211,6 +212,7 @@ class NCManageDatabase: NSObject {
         self.clearTable(tableActivityPreview.self, account: account)
         self.clearTable(tableActivitySubjectRich.self, account: account)
         self.clearTable(tableCapabilities.self, account: account)
+        self.clearTable(tableChunk.self, account: account)
         self.clearTable(tableComments.self, account: account)
         self.clearTable(tableDirectEditingCreators.self, account: account)
         self.clearTable(tableDirectEditingEditors.self, account: account)
@@ -337,7 +339,7 @@ class NCManageDatabase: NSObject {
         }
     }
 
-    @objc func getAccountActive() -> tableAccount? {
+    @objc func getActiveAccount() -> tableAccount? {
         
         let realm = try! Realm()
         
@@ -537,13 +539,13 @@ class NCManageDatabase: NSObject {
         var returnAccount = tableAccount()
 
         do {
-            guard let account = self.getAccountActive() else {
+            guard let activeAccount = self.getActiveAccount() else {
                 return nil
             }
             
             try realm.safeWrite {
                 
-                guard let result = realm.objects(tableAccount.self).filter("account == %@", account.account).first else {
+                guard let result = realm.objects(tableAccount.self).filter("account == %@", activeAccount.account).first else {
                     return
                 }
                 
@@ -586,13 +588,13 @@ class NCManageDatabase: NSObject {
         var returnAccount = tableAccount()
 
         do {
-            guard let account = self.getAccountActive() else {
+            guard let activeAccount = self.getActiveAccount() else {
                 return nil
             }
             
             try realm.safeWrite {
                 
-                guard let result = realm.objects(tableAccount.self).filter("account == %@", account.account).first else {
+                guard let result = realm.objects(tableAccount.self).filter("account == %@", activeAccount.account).first else {
                     return
                 }
                 
@@ -722,6 +724,22 @@ class NCManageDatabase: NSObject {
         }
     }
     
+    @objc func setAccountColorFiles(lightColorBackground: String, darkColorBackground: String) {
+        
+        let realm = try! Realm()
+
+        do {
+            try realm.safeWrite {
+                if let result = realm.objects(tableAccount.self).filter("active == true").first {
+                    result.lightColorBackground = lightColorBackground
+                    result.darkColorBackground = darkColorBackground
+                }
+            }
+        } catch let error {
+            NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+        }
+    }
+    
     //MARK: -
     //MARK: Table Activity
 
@@ -782,6 +800,7 @@ class NCManageDatabase: NSObject {
                                 addObjectActivityPreview.account = account
                                 addObjectActivityPreview.idActivity = activity.idActivity
                                 addObjectActivityPreview.fileId = preview["fileId"].intValue
+                                addObjectActivityPreview.filename = preview["filename"].stringValue
                                 addObjectActivityPreview.idPrimaryKey = account + String(activity.idActivity) + String(addObjectActivityPreview.fileId)
                                 addObjectActivityPreview.source = preview["source"].stringValue
                                 addObjectActivityPreview.link = preview["link"].stringValue
@@ -986,6 +1005,88 @@ class NCManageDatabase: NSObject {
         return nil
     }
     
+    //MARK: -
+    //MARK: Table Chunk
+    
+    func getChunkFolder(account: String, ocId: String) -> String {
+        
+        let realm = try! Realm()
+
+        if let result = realm.objects(tableChunk.self).filter("account == %@ AND ocId == %@", account, ocId).first {
+            return result.chunkFolder
+        }
+        
+        return NSUUID().uuidString
+    }
+    
+    func getChunks(account: String, ocId: String) -> [String] {
+        
+        let realm = try! Realm()
+        var filesNames: [String] = []
+
+        let results = realm.objects(tableChunk.self).filter("account == %@ AND ocId == %@", account, ocId).sorted(byKeyPath: "fileName", ascending: true)
+        for result in results {
+            filesNames.append(result.fileName)
+        }
+        
+        return filesNames
+    }
+    
+    func addChunks(account: String, ocId: String, chunkFolder: String, fileNames: [String]) {
+        
+        let realm = try! Realm()
+        
+        do {
+            try realm.safeWrite {
+                
+                for fileName in fileNames {
+                    
+                    let object = tableChunk()
+                    
+                    object.account = account
+                    object.chunkFolder = chunkFolder
+                    object.fileName = fileName
+                    object.index = ocId + fileName
+                    object.ocId = ocId
+
+                    realm.add(object, update: .all)
+                }
+            }
+        } catch let error {
+            NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+        }
+    }
+    
+    func deleteChunk(account: String, ocId: String, fileName: String) {
+        
+        let realm = try! Realm()
+
+        do {
+            try realm.safeWrite {
+                
+                let result = realm.objects(tableChunk.self).filter(NSPredicate(format: "account == %@ AND ocId == %@ AND fileName == %@", account, ocId, fileName))
+                realm.delete(result)
+            }
+        } catch let error {
+            NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+        }
+    }
+    
+    func deleteChunks(account: String, ocId: String) {
+        
+        let realm = try! Realm()
+
+        do {
+            try realm.safeWrite {
+                
+                let result = realm.objects(tableChunk.self).filter(NSPredicate(format: "account == %@ AND ocId == %@", account, ocId))
+                realm.delete(result)
+            }
+        } catch let error {
+            NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+        }
+    }
+    
     //MARK: -
     //MARK: Table Comments
     
@@ -1384,7 +1485,7 @@ class NCManageDatabase: NSObject {
     
     @objc func getE2eEncryptions(predicate: NSPredicate) -> [tableE2eEncryption]? {
         
-        guard self.getAccountActive() != nil else {
+        guard self.getActiveAccount() != nil else {
             return nil
         }
         
@@ -1403,7 +1504,7 @@ class NCManageDatabase: NSObject {
     
     @objc func renameFileE2eEncryption(serverUrl: String, fileNameIdentifier: String, newFileName: String, newFileNamePath: String) {
         
-        guard let tableAccount = self.getAccountActive() else {
+        guard let activeAccount = self.getActiveAccount() else {
             return
         }
         
@@ -1411,7 +1512,7 @@ class NCManageDatabase: NSObject {
 
         realm.beginWrite()
 
-        guard let result = realm.objects(tableE2eEncryption.self).filter("account == %@ AND serverUrl == %@ AND fileNameIdentifier == %@", tableAccount.account, serverUrl, fileNameIdentifier).first else {
+        guard let result = realm.objects(tableE2eEncryption.self).filter("account == %@ AND serverUrl == %@ AND fileNameIdentifier == %@", activeAccount.account, serverUrl, fileNameIdentifier).first else {
             realm.cancelWrite()
             return 
         }
@@ -1809,18 +1910,18 @@ class NCManageDatabase: NSObject {
         completion(metadataFolder, metadataFolders, metadatas)
     }
     
-    @objc func createMetadata(account: String, fileName: String, fileNameView: String, ocId: String, serverUrl: String, urlBase: String, url: String, contentType: String, livePhoto: Bool, chunk: Bool) -> tableMetadata {
+    @objc func createMetadata(account: String, fileName: String, fileNameView: String, ocId: String, serverUrl: String, urlBase: String, url: String, contentType: String, livePhoto: Bool) -> tableMetadata {
         
         let metadata = tableMetadata()
-        let results = NCCommunicationCommon.shared.getInternalType(fileName: fileName, mimeType: contentType, directory: false)
+        let resultInternalType = NCCommunicationCommon.shared.getInternalType(fileName: fileName, mimeType: contentType, directory: false)
         
         metadata.account = account
-        metadata.chunk = chunk
-        metadata.contentType = results.mimeType
+        metadata.chunk = false
+        metadata.contentType = resultInternalType.mimeType
         metadata.creationDate = Date() as NSDate
         metadata.date = Date() as NSDate
         metadata.hasPreview = true
-        metadata.iconName = results.iconName
+        metadata.iconName = resultInternalType.iconName
         metadata.etag = ocId
         metadata.ext = (fileName as NSString).pathExtension.lowercased()
         metadata.fileName = fileName
@@ -1830,7 +1931,7 @@ class NCManageDatabase: NSObject {
         metadata.ocId = ocId
         metadata.permissions = "RGDNVW"
         metadata.serverUrl = serverUrl
-        metadata.typeFile = results.typeFile
+        metadata.typeFile = resultInternalType.typeFile
         metadata.uploadDate = Date() as NSDate
         metadata.url = url
         metadata.urlBase = urlBase
@@ -2132,20 +2233,6 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    func setMetadataChunked(ocId: String, chunk: Bool) {
-           
-        let realm = try! Realm()
-        
-        do {
-            try realm.safeWrite {
-                let result = realm.objects(tableMetadata.self).filter("ocId == %@", ocId).first
-                result?.chunk = chunk
-            }
-        } catch let error {
-            NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
-        }
-    }
-    
     @objc func getMetadata(predicate: NSPredicate) -> tableMetadata? {
         
         let realm = try! Realm()
@@ -2816,9 +2903,11 @@ class NCManageDatabase: NSObject {
         }
     }
     
-    @objc func getTrash(filePath: String, sort: String, ascending: Bool, account: String) -> [tableTrash]? {
+    func getTrash(filePath: String, sort: String?, ascending: Bool?, account: String) -> [tableTrash]? {
         
         let realm = try! Realm()
+        let sort = sort ?? "date"
+        let ascending = ascending ?? false
         
         let results = realm.objects(tableTrash.self).filter("account == %@ AND filePath == %@", account, filePath).sorted(byKeyPath: sort, ascending: ascending)
 
@@ -2908,6 +2997,20 @@ class NCManageDatabase: NSObject {
         return time
     }
     
+    func deleteVideoTime(metadata: tableMetadata) {
+        
+        let realm = try! Realm()
+
+        do {
+            try realm.safeWrite {
+                let result = realm.objects(tableVideo.self).filter("account == %@ AND ocId == %@", metadata.account, metadata.ocId)
+                realm.delete(result)
+            }
+        } catch let error {
+            NCCommunicationCommon.shared.writeLog("Could not write to database: \(error)")
+        }
+    }
+    
     //MARK: -
 }
 

+ 22 - 4
iOSClient/Diagnostics/NCCapabilitiesViewController.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="vTK-Er-kbZ">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="vTK-Er-kbZ">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17505"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -41,6 +41,7 @@
                                                     </label>
                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SbT-rU-lJ8">
                                                         <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                                         <constraints>
                                                             <constraint firstAttribute="height" constant="25" id="Yf6-Er-ibu"/>
                                                             <constraint firstAttribute="width" constant="120" id="bqY-hB-VuU"/>
@@ -80,6 +81,7 @@
                                                     </label>
                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ivv-te-kaP">
                                                         <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                                         <constraints>
                                                             <constraint firstAttribute="width" constant="120" id="KRE-Ez-UvG"/>
                                                             <constraint firstAttribute="height" constant="25" id="xhy-Qg-h6R"/>
@@ -119,6 +121,7 @@
                                                     </label>
                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="M82-8U-M4Q">
                                                         <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                                         <constraints>
                                                             <constraint firstAttribute="height" constant="25" id="L0G-30-siH"/>
                                                             <constraint firstAttribute="width" constant="120" id="z0Z-Hz-edq"/>
@@ -158,6 +161,7 @@
                                                     </label>
                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dyb-1O-dIA">
                                                         <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                                         <constraints>
                                                             <constraint firstAttribute="height" constant="25" id="C3a-Ec-xJv"/>
                                                             <constraint firstAttribute="width" constant="120" id="IB5-Hq-R4j"/>
@@ -196,6 +200,7 @@
                                                     </label>
                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WAg-Hw-sQS">
                                                         <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                                         <constraints>
                                                             <constraint firstAttribute="height" constant="25" id="NEz-tu-8Rk"/>
                                                             <constraint firstAttribute="width" constant="120" id="zjs-JE-2aB"/>
@@ -234,6 +239,7 @@
                                                     </label>
                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8hg-qK-qvz">
                                                         <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                                         <constraints>
                                                             <constraint firstAttribute="width" constant="120" id="Ns2-PG-H7R"/>
                                                             <constraint firstAttribute="height" constant="25" id="b2x-qE-hf6"/>
@@ -272,6 +278,7 @@
                                                     </label>
                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uiz-H8-p3D">
                                                         <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                                         <constraints>
                                                             <constraint firstAttribute="height" constant="25" id="Eqf-R1-eKB"/>
                                                             <constraint firstAttribute="width" constant="120" id="i0a-tu-JgU"/>
@@ -310,6 +317,7 @@
                                                     </label>
                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="30w-oC-gZl">
                                                         <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                                         <constraints>
                                                             <constraint firstAttribute="height" constant="25" id="E6x-vP-Fs9"/>
                                                             <constraint firstAttribute="width" constant="120" id="nGc-gZ-jaG"/>
@@ -348,6 +356,7 @@
                                                     </label>
                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ucV-YG-5ht">
                                                         <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                                         <constraints>
                                                             <constraint firstAttribute="height" constant="25" id="8Xe-4g-RxY"/>
                                                             <constraint firstAttribute="width" constant="120" id="m3G-CE-aso"/>
@@ -386,6 +395,7 @@
                                                     </label>
                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Sj-5h-jgb">
                                                         <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                                         <constraints>
                                                             <constraint firstAttribute="width" constant="120" id="IJ3-gv-UjC"/>
                                                             <constraint firstAttribute="height" constant="25" id="wiA-JQ-GDr"/>
@@ -424,6 +434,7 @@
                                                     </label>
                                                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Available" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lVT-MG-7kN">
                                                         <rect key="frame" x="279" y="12.5" width="120" height="25"/>
+                                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                                         <constraints>
                                                             <constraint firstAttribute="width" constant="120" id="TPY-VV-LmQ"/>
                                                             <constraint firstAttribute="height" constant="25" id="WwT-hU-yOT"/>
@@ -539,7 +550,8 @@
                                         <subviews>
                                             <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="RIO-6X-GG1">
                                                 <rect key="frame" x="5" y="5" width="404" height="30.5"/>
-                                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                                <color key="backgroundColor" systemColor="systemGray4Color"/>
+                                                <color key="textColor" systemColor="labelColor"/>
                                                 <fontDescription key="fontDescription" type="system" pointSize="12"/>
                                                 <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
                                             </textView>
@@ -639,14 +651,20 @@
         <image name="delete" width="425" height="425"/>
         <image name="externalsites" width="425" height="425"/>
         <image name="home" width="425" height="425"/>
-        <image name="lock" width="300" height="300"/>
+        <image name="lock" width="24" height="24"/>
         <image name="notification" width="512" height="512"/>
         <image name="onlyoffice" width="425" height="425"/>
         <image name="share" width="512" height="512"/>
         <image name="text" width="425" height="425"/>
         <image name="userStatusAway" width="425" height="425"/>
+        <systemColor name="labelColor">
+            <color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
         <systemColor name="systemBackgroundColor">
             <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
         </systemColor>
+        <systemColor name="systemGray4Color">
+            <color red="0.81960784313725488" green="0.81960784313725488" blue="0.83921568627450982" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
     </resources>
 </document>

+ 41 - 39
iOSClient/Diagnostics/NCCapabilitiesViewController.swift

@@ -73,6 +73,8 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
     private var capabilitiesText = ""
     //private var timer: Timer?
     
+    // MARK: - View Life Cycle
+
     override func viewDidLoad() {
         super.viewDidLoad()
         
@@ -83,93 +85,93 @@ class NCCapabilitiesViewController: UIViewController, UIDocumentInteractionContr
         self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_done_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(close))
 
         textView.layer.cornerRadius = 15
-        textView.backgroundColor = NCBrandColor.shared.graySoft
+        textView.layer.masksToBounds = true
         
         statusFileSharing.layer.cornerRadius = 12.5
         statusFileSharing.layer.borderWidth = 0.5
         statusFileSharing.layer.borderColor = UIColor.gray.cgColor
-        statusFileSharing.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
-        
+        statusFileSharing.layer.masksToBounds = true
+
         statusExternalSite.layer.cornerRadius = 12.5
         statusExternalSite.layer.borderWidth = 0.5
         statusExternalSite.layer.borderColor = UIColor.gray.cgColor
-        statusExternalSite.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
-        
+        statusExternalSite.layer.masksToBounds = true
+
         statusEndToEndEncryption.layer.cornerRadius = 12.5
         statusEndToEndEncryption.layer.borderWidth = 0.5
         statusEndToEndEncryption.layer.borderColor = UIColor.gray.cgColor
-        statusEndToEndEncryption.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
-        
+        statusEndToEndEncryption.layer.masksToBounds = true
+
         statusActivity.layer.cornerRadius = 12.5
         statusActivity.layer.borderWidth = 0.5
         statusActivity.layer.borderColor = UIColor.gray.cgColor
-        statusActivity.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
-        
+        statusActivity.layer.masksToBounds = true
+
         statusNotification.layer.cornerRadius = 12.5
         statusNotification.layer.borderWidth = 0.5
         statusNotification.layer.borderColor = UIColor.gray.cgColor
-        statusNotification.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
-        
+        statusNotification.layer.masksToBounds = true
+
         statusDeletedFiles.layer.cornerRadius = 12.5
         statusDeletedFiles.layer.borderWidth = 0.5
         statusDeletedFiles.layer.borderColor = UIColor.gray.cgColor
-        statusDeletedFiles.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
-        
+        statusDeletedFiles.layer.masksToBounds = true
+
         statusText.layer.cornerRadius = 12.5
         statusText.layer.borderWidth = 0.5
         statusText.layer.borderColor = UIColor.gray.cgColor
-        statusText.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
+        statusText.layer.masksToBounds = true
 
         statusCollabora.layer.cornerRadius = 12.5
         statusCollabora.layer.borderWidth = 0.5
         statusCollabora.layer.borderColor = UIColor.gray.cgColor
-        statusCollabora.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
- 
+        statusCollabora.layer.masksToBounds = true
+
         statusOnlyOffice.layer.cornerRadius = 12.5
         statusOnlyOffice.layer.borderWidth = 0.5
         statusOnlyOffice.layer.borderColor = UIColor.gray.cgColor
-        statusOnlyOffice.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
-        
+        statusOnlyOffice.layer.masksToBounds = true
+
         statusUserStatus.layer.cornerRadius = 12.5
         statusUserStatus.layer.borderWidth = 0.5
         statusUserStatus.layer.borderColor = UIColor.gray.cgColor
-        statusUserStatus.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
-        
+        statusUserStatus.layer.masksToBounds = true
+
         statusComments.layer.cornerRadius = 12.5
         statusComments.layer.borderWidth = 0.5
         statusComments.layer.borderColor = UIColor.gray.cgColor
-        statusComments.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
-        
-        imageFileSharing.image = UIImage.init(named: "share")!.image(color: .gray, size: 50)
-        imageExternalSite.image = NCUtility.shared.loadImage(named: "network", color: .gray)
-        imageEndToEndEncryption.image = NCUtility.shared.loadImage(named: "lock", color: .gray)
-        imageActivity.image = UIImage.init(named: "bolt")!.image(color: .gray, size: 50)
-        imageNotification.image = NCUtility.shared.loadImage(named: "bell", color: .gray)
-        imageDeletedFiles.image = NCUtility.shared.loadImage(named: "trash", color: .gray)
-        imageText.image = UIImage.init(named: "text")!.image(color: .gray, size: 50)
-        imageCollabora.image = UIImage.init(named: "collabora")!.image(color: .gray, size: 50)
-        imageOnlyOffice.image = UIImage.init(named: "onlyoffice")!.image(color: .gray, size: 50)
-        imageUserStatus.image = UIImage.init(named: "userStatusAway")!.image(color: .gray, size: 50)
-        imageComments.image = UIImage.init(named: "comments")!.image(color: .gray, size: 50)
+        statusComments.layer.masksToBounds = true
+
+        imageFileSharing.image = UIImage.init(named: "share")!.image(color: NCBrandColor.shared.gray, size: 50)
+        imageExternalSite.image = NCUtility.shared.loadImage(named: "network", color: NCBrandColor.shared.gray)
+        imageEndToEndEncryption.image = NCUtility.shared.loadImage(named: "lock", color: NCBrandColor.shared.gray)
+        imageActivity.image = UIImage.init(named: "bolt")!.image(color: NCBrandColor.shared.gray, size: 50)
+        imageNotification.image = NCUtility.shared.loadImage(named: "bell", color: NCBrandColor.shared.gray)
+        imageDeletedFiles.image = NCUtility.shared.loadImage(named: "trash", color: NCBrandColor.shared.gray)
+        imageText.image = UIImage.init(named: "text")!.image(color: NCBrandColor.shared.gray, size: 50)
+        imageCollabora.image = UIImage.init(named: "collabora")!.image(color: NCBrandColor.shared.gray, size: 50)
+        imageOnlyOffice.image = UIImage.init(named: "onlyoffice")!.image(color: NCBrandColor.shared.gray, size: 50)
+        imageUserStatus.image = UIImage.init(named: "userStatusAway")!.image(color: NCBrandColor.shared.gray, size: 50)
+        imageComments.image = UIImage.init(named: "comments")!.image(color: NCBrandColor.shared.gray, size: 50)
 
-        guard let account = NCManageDatabase.shared.getAccountActive() else { return }
-        self.account = account.account
+        guard let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return }
+        self.account = activeAccount.account
         
-        if let text = NCManageDatabase.shared.getCapabilities(account: account.account) {
+        if let text = NCManageDatabase.shared.getCapabilities(account: activeAccount.account) {
             capabilitiesText = text
             updateCapabilities()
         } else {
-            NCContentPresenter.shared.messageNotification("_error_", description: "_no_capabilities_found_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.ErrorInternalError, forced: true)
+            NCContentPresenter.shared.messageNotification("_error_", description: "_no_capabilities_found_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorInternalError, forced: true)
             
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
                 self.dismiss(animated: true, completion: nil)
             }
         }
         
-        homeImage.image = UIImage.init(named: "home")!.image(color: .gray, size: 50)
+        homeImage.image = UIImage.init(named: "home")!.image(color: NCBrandColor.shared.gray, size: 50)
         homeServer.text = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) + "/"
         
-        davImage.image = UIImage.init(named: "dav")!.image(color: .gray, size: 50)
+        davImage.image = UIImage.init(named: "dav")!.image(color: NCBrandColor.shared.gray, size: 50)
         davFiles.text = appDelegate.urlBase + "/" + NCUtilityFileSystem.shared.getDAV() + "/files/" + appDelegate.user + "/"
     }
 

+ 48 - 28
iOSClient/EmptyView/NCEmptyDataSet.swift

@@ -5,23 +5,46 @@
 //  Created by Marino Faggiana on 19/10/2020.
 //  Copyright © 2020 Marino Faggiana. All rights reserved.
 //
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//
+//  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
 
-import Foundation
+public protocol NCEmptyDataSetDelegate {
+    func emptyDataSetView(_ view: NCEmptyView)
+}
 
-@objc public protocol NCEmptyDataSetDelegate {
-    @objc optional func emptyDataSetView(_ view: NCEmptyView)
+// optional func
+public extension NCEmptyDataSetDelegate {
+    func emptyDataSetView(_ view: NCEmptyView) {}
 }
 
 class NCEmptyDataSet: NSObject {
     
-    var emptyView: NCEmptyView?
-    var delegate: NCEmptyDataSetDelegate?
-    var timer: Timer?
-    var numberItemsForSections: Int = 0
-    
+    private var emptyView: NCEmptyView?
+    private var timer: Timer?
+    private var numberItemsForSections: Int = 0
+    private var delegate: NCEmptyDataSetDelegate?
+
+    private var fillBackgroundName: String = ""
+    private var fillBackgroundView = UIImageView()
+
     init(view: UIView, offset: CGFloat = 0, delegate: NCEmptyDataSetDelegate?) {
         super.init()
-
+                
         if let emptyView = UINib(nibName: "NCEmptyView", bundle: nil).instantiate(withOwner: self, options: nil).first as? NCEmptyView {
         
             self.delegate = delegate
@@ -30,23 +53,26 @@ class NCEmptyDataSet: NSObject {
             emptyView.isHidden = true
             emptyView.translatesAutoresizingMaskIntoConstraints = false
             
-            //emptyView.backgroundColor = .red
-            //emptyView.isHidden = false
+//            emptyView.backgroundColor = .red
+//            emptyView.isHidden = false
             
             emptyView.emptyTitle.sizeToFit()
             emptyView.emptyDescription.sizeToFit()
-            
+                          
             view.addSubview(emptyView)
-            
-            let constantTop: CGFloat = (view.frame.height - emptyView.frame.height) / 2 - offset
-            
-            emptyView.widthAnchor.constraint(equalToConstant: view.frame.width).isActive = true
-            emptyView.heightAnchor.constraint(equalToConstant: 350).isActive = true
-            emptyView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
-            emptyView.topAnchor.constraint(equalTo: view.topAnchor, constant: constantTop).isActive = true
+
+            emptyView.widthAnchor.constraint(equalToConstant: 350).isActive = true
+            emptyView.heightAnchor.constraint(equalToConstant: 250).isActive = true
+            if let view = view.superview {
+                emptyView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
+                emptyView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: offset).isActive = true
+            } else {
+                emptyView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
+                emptyView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: offset).isActive = true
+            }
         }
     }
-    
+        
     func numberOfItemsInSection(_ num: Int, section: Int) {
         
         if section == 0 {
@@ -57,7 +83,7 @@ class NCEmptyDataSet: NSObject {
         
         if let emptyView = emptyView {
             
-            self.delegate?.emptyDataSetView?(emptyView)
+            self.delegate?.emptyDataSetView(emptyView)
             
             if !(timer?.isValid ?? false) && emptyView.isHidden == true {
                 timer = Timer.scheduledTimer(timeInterval: 0.3, target: self, selector: #selector(timerHandler(_:)), userInfo: nil, repeats: false)
@@ -88,12 +114,6 @@ public class NCEmptyView: UIView {
     public override func awakeFromNib() {
         super.awakeFromNib()
         
-        NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
-        changeTheming()
-    }
-    
-    @objc func changeTheming() {
-        emptyTitle.textColor = NCBrandColor.shared.textView
+        emptyTitle.textColor = NCBrandColor.shared.label
     }
 }
-

+ 8 - 7
iOSClient/EmptyView/NCEmptyView.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina3_5" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17126"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -12,24 +12,24 @@
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
         <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
         <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="NCEmptyView" customModule="Nextcloud" customModuleProvider="target">
-            <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
+            <rect key="frame" x="0.0" y="0.0" width="350" height="250"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="W3d-Us-kU4">
-                    <rect key="frame" x="85" y="0.0" width="150" height="150"/>
+                    <rect key="frame" x="100" y="0.0" width="150" height="150"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="150" id="A8B-y7-Fre"/>
                         <constraint firstAttribute="width" constant="150" id="g0C-P6-l3d"/>
                     </constraints>
                 </imageView>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="crs-DO-owR">
-                    <rect key="frame" x="0.0" y="180" width="320" height="24"/>
+                    <rect key="frame" x="0.0" y="180" width="350" height="24"/>
                     <fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
                     <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     <nil key="highlightedColor"/>
                 </label>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D4p-sI-mNB">
-                    <rect key="frame" x="20" y="224" width="280" height="17"/>
+                    <rect key="frame" x="20" y="224" width="310" height="17"/>
                     <constraints>
                         <constraint firstAttribute="height" relation="lessThanOrEqual" constant="50" id="u7B-jW-bWI"/>
                     </constraints>
@@ -50,12 +50,13 @@
                 <constraint firstItem="W3d-Us-kU4" firstAttribute="centerX" secondItem="vUN-kp-3ea" secondAttribute="centerX" id="kma-1Q-c3Q"/>
                 <constraint firstItem="D4p-sI-mNB" firstAttribute="top" secondItem="crs-DO-owR" secondAttribute="bottom" constant="20" id="zbi-5P-raN"/>
             </constraints>
+            <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
             <connections>
                 <outlet property="emptyDescription" destination="D4p-sI-mNB" id="4Rw-TK-oGc"/>
                 <outlet property="emptyImage" destination="W3d-Us-kU4" id="xtd-nV-OUc"/>
                 <outlet property="emptyTitle" destination="crs-DO-owR" id="IkU-6d-P64"/>
             </connections>
-            <point key="canvasLocation" x="-146" y="65"/>
+            <point key="canvasLocation" x="-146.25" y="32.5"/>
         </view>
     </objects>
     <resources>

+ 13 - 7
iOSClient/Main/ActionSheetHeaderView/NCActionSheetHeaderView.swift → iOSClient/Extensions/NSMutableAttributedString+Extensions.swift

@@ -1,9 +1,9 @@
 //
-//  NCActionSheetHeaderView.swift
+//  UI+Extensions.swift
 //  Nextcloud
 //
-//  Created by Marino Faggiana on 08/10/2018.
-//  Copyright © 2018 Marino Faggiana. All rights reserved.
+//  Created by Marino Faggiana on 26/05/21.
+//  Copyright © 2021 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
 //
@@ -24,9 +24,15 @@
 import Foundation
 import UIKit
 
-class NCActionSheetHeaderView: UIView {
-    
-    @IBOutlet weak var imageItem: UIImageView!
-    @IBOutlet weak var label: UILabel!
+extension NSMutableAttributedString {
 
+    func setColor(color: UIColor, font: UIFont? = nil, forText stringValue: String) {
+        
+        let range: NSRange = self.mutableString.range(of: stringValue, options: .caseInsensitive)
+        
+        self.addAttribute(NSAttributedString.Key.foregroundColor, value: color, range: range)
+        if let font = font {
+            self.addAttribute(NSAttributedString.Key.font, value: font, range: range)
+        }
+    }
 }

+ 1 - 0
iOSClient/Extensions/NSNotificationCenter+MainThread.h

@@ -22,6 +22,7 @@
 //
 
 #import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
 
 @interface NSNotificationCenter (MainThread)
 

+ 1 - 0
iOSClient/Extensions/NotificationCenter+MainThread.swift

@@ -22,6 +22,7 @@
 //
 
 import Foundation
+import UIKit
 
 extension NotificationCenter {
 

+ 1 - 0
iOSClient/Extensions/String+Extensions.swift

@@ -22,6 +22,7 @@
 //
 
 import Foundation
+import UIKit
 
 extension String {
     

+ 31 - 0
iOSClient/Extensions/UIColor+Extensions.swift

@@ -22,9 +22,33 @@
 //
 
 import Foundation
+import UIKit
 
 extension UIColor {
     
+    var hexString: String {
+            
+        let cgColorInRGB = cgColor.converted(to: CGColorSpace(name: CGColorSpace.sRGB)!, intent: .defaultIntent, options: nil)!
+        let colorRef = cgColorInRGB.components
+        let r = colorRef?[0] ?? 0
+        let g = colorRef?[1] ?? 0
+        let b = ((colorRef?.count ?? 0) > 2 ? colorRef?[2] : g) ?? 0
+        let a = cgColor.alpha
+
+        var color = String(
+            format: "#%02lX%02lX%02lX",
+            lroundf(Float(r * 255)),
+            lroundf(Float(g * 255)),
+            lroundf(Float(b * 255))
+        )
+
+        if a < 1 {
+            color += String(format: "%02lX", lroundf(Float(a * 255)))
+        }
+
+        return color
+    }
+    
     @objc convenience init?(hex: String) {
 
         let r, g, b, a: CGFloat
@@ -114,4 +138,11 @@ extension UIColor {
         let brightness = Float(((components[0] * 299) + (components[1] * 587) + (components[2] * 114)) / 1000)
         return (brightness > threshold)
     }
+    
+    func image(_ size: CGSize = CGSize(width: 1, height: 1)) -> UIImage {
+        return UIGraphicsImageRenderer(size: size).image { rendererContext in
+            self.setFill()
+            rendererContext.fill(CGRect(origin: .zero, size: size))
+        }
+    }
 }

+ 1 - 0
iOSClient/Extensions/UIImage+Extensions.swift

@@ -22,6 +22,7 @@
 //
 
 import Foundation
+import UIKit
 import Accelerate
 
 extension UIImage {

+ 28 - 7
iOSClient/Extensions/UIImage+animatedGIF.h

@@ -1,14 +1,35 @@
+//
+//  UIImage+animatedGIF
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 28/05/17.
+//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//  Found in Internet
+//
+//  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 <Foundation/Foundation.h>
 #import <UIKit/UIKit.h>
+#import <ImageIO/ImageIO.h>
 
-/**
-        UIImage (animatedGIF)
-        
-    This category adds class methods to `UIImage` to create an animated `UIImage` from an animated GIF.
-*/
 @interface UIImage (animatedGIF)
 
 /*
-        UIImage *animation = [UIImage animatedImageWithAnimatedGIFData:theData];
+    UIImage *animation = [UIImage animatedImageWithAnimatedGIFData:theData];
     
     I interpret `theData` as a GIF.  I create an animated `UIImage` using the source images in the GIF.
     
@@ -21,7 +42,7 @@
 + (UIImage *)animatedImageWithAnimatedGIFData:(NSData *)theData;
 
 /*
-        UIImage *image = [UIImage animatedImageWithAnimatedGIFURL:theURL];
+    UIImage *image = [UIImage animatedImageWithAnimatedGIFURL:theURL];
     
     I interpret the contents of `theURL` as a GIF.  I create an animated `UIImage` using the source images in the GIF.
     

+ 24 - 1
iOSClient/Extensions/UIImage+animatedGIF.m

@@ -1,5 +1,28 @@
+//
+//  UIImage+animatedGIF
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 28/05/17.
+//  Copyright (c) 2017 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//  Found in Internet
+//
+//  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 "UIImage+animatedGIF.h"
-#import <ImageIO/ImageIO.h>
 
 #if __has_feature(objc_arc)
 #define toCF (__bridge CFTypeRef)

+ 4 - 2
iOSClient/Favorites/NCFavorite.swift

@@ -21,11 +21,13 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 import NCCommunication
 
 class NCFavorite: NCCollectionViewCommon  {
     
+    // MARK: - View Life Cycle
+
     required init?(coder aDecoder: NSCoder) {
         super.init(coder: aDecoder)
         
@@ -53,7 +55,7 @@ class NCFavorite: NCCollectionViewCommon  {
                 }
             }
             
-            self.dataSource = NCDataSource.init(metadatasSource: self.metadatasSource, sort:self.sort, ascending: self.ascending, directoryOnTop: self.directoryOnTop, favoriteOnTop: true, filterLivePhoto: true)
+            self.dataSource = NCDataSource.init(metadatasSource: self.metadatasSource, sort:self.layoutForView?.sort, ascending: self.layoutForView?.ascending, directoryOnTop: self.layoutForView?.directoryOnTop, favoriteOnTop: true, filterLivePhoto: true)
             
             DispatchQueue.main.async {
                 self.refreshControl.endRefreshing()

+ 8 - 5
iOSClient/FileViewInFolder/NCFileViewInFolder.swift

@@ -21,13 +21,15 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 import NCCommunication
 
 class NCFileViewInFolder: NCCollectionViewCommon  {
     
     internal var fileName: String?
 
+    // MARK: - View Life Cycle
+
     required init?(coder aDecoder: NSCoder) {
         super.init(coder: aDecoder)
         
@@ -41,6 +43,7 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
     }
     
     override func viewWillAppear(_ animated: Bool) {
+
         appDelegate.activeViewController = self
         
         if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
@@ -51,10 +54,10 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
         
         presentationController?.delegate = self
         
-        (layout, sort, ascending, groupBy, directoryOnTop, titleButton, itemForLine) = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
-        gridLayout.itemForLine = CGFloat(itemForLine)
+        layoutForView = NCUtility.shared.getLayoutForView(key: layoutKey, serverUrl: serverUrl)
+        gridLayout.itemForLine = CGFloat(layoutForView?.itemForLine ?? 3)
         
-        if layout == NCGlobal.shared.layoutList {
+        if layoutForView?.layout == NCGlobal.shared.layoutList {
             collectionView?.collectionViewLayout = listLayout
         } else {
             collectionView?.collectionViewLayout = gridLayout
@@ -86,7 +89,7 @@ class NCFileViewInFolder: NCCollectionViewCommon  {
                 }
             }
             
-            self.dataSource = NCDataSource.init(metadatasSource: self.metadatasSource, sort: self.sort, ascending: self.ascending, directoryOnTop: self.directoryOnTop, favoriteOnTop: true, filterLivePhoto: true)
+            self.dataSource = NCDataSource.init(metadatasSource: self.metadatasSource, sort: self.layoutForView?.sort, ascending: self.layoutForView?.ascending, directoryOnTop: self.layoutForView?.directoryOnTop, favoriteOnTop: true, filterLivePhoto: true)
             
             DispatchQueue.main.async {
             

+ 6 - 4
iOSClient/Files/NCFiles.swift

@@ -21,13 +21,15 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 import NCCommunication
 
 class NCFiles: NCCollectionViewCommon  {
     
     internal var isRoot: Bool = true
 
+    // MARK: - View Life Cycle
+
     required init?(coder aDecoder: NSCoder) {
         super.init(coder: aDecoder)
         
@@ -51,14 +53,14 @@ class NCFiles: NCCollectionViewCommon  {
     
     // MARK: - NotificationCenter
     
-    override func initializeMain() {
+    override func initialize() {
         
         if isRoot {
             serverUrl = NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
             reloadDataSourceNetwork(forced: true)
         }
         
-        super.initializeMain()
+        super.initialize()
     }
     
     // MARK: - DataSource + NC Endpoint
@@ -75,7 +77,7 @@ class NCFiles: NCCollectionViewCommon  {
                 }
             }
             
-            self.dataSource = NCDataSource.init(metadatasSource: self.metadatasSource, sort: self.sort, ascending: self.ascending, directoryOnTop: self.directoryOnTop, favoriteOnTop: true, filterLivePhoto: true)
+            self.dataSource = NCDataSource.init(metadatasSource: self.metadatasSource, sort: self.layoutForView?.sort, ascending: self.layoutForView?.ascending, directoryOnTop: self.layoutForView?.directoryOnTop, favoriteOnTop: true, filterLivePhoto: true)
             
             DispatchQueue.main.async { [weak self] in
                 self?.refreshControl.endRefreshing()

+ 26 - 0
iOSClient/Images.xcassets/back.imageset/Contents.json

@@ -0,0 +1,26 @@
+{
+  "images" : [
+    {
+      "filename" : "back.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "back-1.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "back-2.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

BIN
iOSClient/Images.xcassets/back.imageset/back-1.png


BIN
iOSClient/Images.xcassets/back.imageset/back-2.png


BIN
iOSClient/Images.xcassets/back.imageset/back.png


+ 5 - 5
iOSClient/Images.xcassets/exit.imageset/Contents.json → iOSClient/Images.xcassets/certificate.imageset/Contents.json

@@ -1,15 +1,15 @@
 {
   "images" : [
     {
-      "idiom" : "universal",
-      "filename" : "exit.pdf"
+      "filename" : "certificate.svg",
+      "idiom" : "universal"
     }
   ],
   "info" : {
-    "version" : 1,
-    "author" : "xcode"
+    "author" : "xcode",
+    "version" : 1
   },
   "properties" : {
     "preserves-vector-representation" : true
   }
-}
+}

+ 1 - 0
iOSClient/Images.xcassets/certificate.imageset/certificate.svg

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M14 13V11L12 12L10 11V13L8 14L10 15V17L12 16L14 17V15L16 14M14 2H7A2 2 0 0 0 5 4V18A2 2 0 0 0 7 20H8V18H7V4H13V8H17V18H16V20H17A2 2 0 0 0 19 18V7M14 13V11L12 12L10 11V13L8 14L10 15V17L12 16L14 17V15L16 14M10 23L12 22L14 23V18H10M14 13V11L12 12L10 11V13L8 14L10 15V17L12 16L14 17V15L16 14Z" /></svg>

+ 0 - 51
iOSClient/Images.xcassets/exit.imageset/exit.pdf

@@ -1,51 +0,0 @@
-%PDF-1.4
-%Óëéá
-1 0 obj
-<</Creator (Chromium)
-/Producer (Skia/PDF m66)
-/CreationDate (D:20190307154558+00'00')
-/ModDate (D:20190307154558+00'00')>>
-endobj
-2 0 obj
-<</Filter /FlateDecode
-/Length 137>> stream
-xœUNË!¼ÏWôl²ØÂÊÂxöäl|Xõÿ[Ô…m™ig„X{½3Ížà±óºà¼£‡N%¹éPÕ
©|dº½!#‰wêÐò´ #º*H”]ÌVIYXq]ŠËÚlqÅæñ6	5›åÇÎÙÅT:’éÚÒw¼yïŽ+NÚOÇ6
-endstream
-endobj
-3 0 obj
-<</Type /Catalog
-/Pages 4 0 R>>
-endobj
-4 0 obj
-<</Type /Pages
-/Count 1
-/Kids [5 0 R]>>
-endobj
-5 0 obj
-<</Type /Page
-/Resources <</ProcSets [/PDF /Text /ImageB /ImageC /ImageI]
-/ExtGState <</G0 6 0 R>>>>
-/MediaBox [0 0 300 300]
-/Contents 2 0 R
-/Parent 4 0 R>>
-endobj
-6 0 obj
-<</ca 1
-/BM /Normal>>
-endobj
-xref
-0 7
-0000000000 65535 f 
-0000000015 00000 n 
-0000000154 00000 n 
-0000000361 00000 n 
-0000000408 00000 n 
-0000000463 00000 n 
-0000000635 00000 n 
-trailer
-<</Size 7
-/Root 3 0 R
-/Info 1 0 R>>
-startxref
-672
-%%EOF

BIN
iOSClient/Images.xcassets/exitCircle.imageset/exitCircle.pdf


+ 6 - 6
iOSClient/Images.xcassets/moreAvatar.imageset/Contents.json → iOSClient/Images.xcassets/gitHub.imageset/Contents.json

@@ -1,23 +1,23 @@
 {
   "images" : [
     {
+      "filename" : "github.png",
       "idiom" : "universal",
-      "filename" : "moreAvatar.png",
       "scale" : "1x"
     },
     {
+      "filename" : "github@2x.png",
       "idiom" : "universal",
-      "filename" : "moreAvatar@2x.png",
       "scale" : "2x"
     },
     {
+      "filename" : "github@3x.png",
       "idiom" : "universal",
-      "filename" : "moreAvatar@3x.png",
       "scale" : "3x"
     }
   ],
   "info" : {
-    "version" : 1,
-    "author" : "xcode"
+    "author" : "xcode",
+    "version" : 1
   }
-}
+}

BIN
iOSClient/Images.xcassets/gitHub.imageset/github.png


BIN
iOSClient/Images.xcassets/gitHub.imageset/github@2x.png


BIN
iOSClient/Images.xcassets/gitHub.imageset/github@3x.png


+ 5 - 5
iOSClient/Images.xcassets/exitCircle.imageset/Contents.json → iOSClient/Images.xcassets/lock-question.imageset/Contents.json

@@ -1,15 +1,15 @@
 {
   "images" : [
     {
-      "idiom" : "universal",
-      "filename" : "exitCircle.pdf"
+      "filename" : "lock-question.svg",
+      "idiom" : "universal"
     }
   ],
   "info" : {
-    "version" : 1,
-    "author" : "xcode"
+    "author" : "xcode",
+    "version" : 1
   },
   "properties" : {
     "preserves-vector-representation" : true
   }
-}
+}

+ 1 - 0
iOSClient/Images.xcassets/lock-question.imageset/lock-question.svg

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M12,1C9.24,1 7,3.24 7,6V8H6C4.9,8 4,8.9 4,10V20C4,21.1 4.9,22 6,22H18C19.1,22 20,21.1 20,20V10C20,8.9 19.1,8 18,8H17V6C17,3.24 14.76,1 12,1M12,2.9C13.71,2.9 15.1,4.29 15.1,6V8H8.9V6C8.9,4.29 10.29,2.9 12,2.9M12.19,10.5C13.13,10.5 13.88,10.71 14.42,11.12C14.96,11.54 15.23,12.1 15.23,12.8C15.23,13.24 15.08,13.63 14.79,14C14.5,14.36 14.12,14.64 13.66,14.85C13.4,15 13.23,15.15 13.14,15.32C13.05,15.5 13,15.72 13,16H11C11,15.5 11.1,15.16 11.29,14.92C11.5,14.68 11.84,14.4 12.36,14.08C12.62,13.94 12.83,13.76 13,13.54C13.14,13.33 13.22,13.08 13.22,12.8C13.22,12.5 13.13,12.28 12.95,12.11C12.77,11.93 12.5,11.85 12.19,11.85C11.92,11.85 11.7,11.92 11.5,12.06C11.34,12.2 11.24,12.41 11.24,12.69H9.27C9.22,12 9.5,11.4 10.05,11.04C10.59,10.68 11.3,10.5 12.19,10.5M11,17H13V19H11V17Z" /></svg>

+ 12 - 0
iOSClient/Images.xcassets/mac.imageset/Contents.json

@@ -0,0 +1,12 @@
+{
+  "images" : [
+    {
+      "filename" : "mac.png",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
iOSClient/Images.xcassets/mac.imageset/mac.png


BIN
iOSClient/Images.xcassets/moreAvatar.imageset/moreAvatar.png


BIN
iOSClient/Images.xcassets/moreAvatar.imageset/moreAvatar@2x.png


BIN
iOSClient/Images.xcassets/moreAvatar.imageset/moreAvatar@3x.png


+ 26 - 0
iOSClient/Images.xcassets/shield.checkerboard.imageset/Contents.json

@@ -0,0 +1,26 @@
+{
+  "images" : [
+    {
+      "filename" : "privacy.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "privacy@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "privacy@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "preserves-vector-representation" : true
+  }
+}

BIN
iOSClient/Images.xcassets/shield.checkerboard.imageset/privacy.png


BIN
iOSClient/Images.xcassets/shield.checkerboard.imageset/privacy@2x.png


BIN
iOSClient/Images.xcassets/shield.checkerboard.imageset/privacy@3x.png


+ 8 - 6
iOSClient/Login/NCAppConfigView.swift

@@ -21,7 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 import NCCommunication
 
 class NCAppConfigView: UIViewController {
@@ -35,6 +35,8 @@ class NCAppConfigView: UIViewController {
     @IBOutlet weak var logoImage: UIImageView!
     @IBOutlet weak var titleLabel: UILabel!
     
+    // MARK: - View Life Cycle
+
     override func viewDidLoad() {
         super.viewDidLoad()
         
@@ -61,15 +63,15 @@ class NCAppConfigView: UIViewController {
         appDelegate.timerErrorNetworking?.invalidate()
         
         guard let serverUrl = self.serverUrl else {
-            NCContentPresenter.shared.messageNotification("_error_", description: "User Default, serverUrl not found", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.ErrorInternalError, forced: true)
+            NCContentPresenter.shared.messageNotification("_error_", description: "User Default, serverUrl not found", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorInternalError, forced: true)
             return
         }
         guard let username = self.username else {
-            NCContentPresenter.shared.messageNotification("_error_", description: "User Default, username not found", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.ErrorInternalError, forced: true)
+            NCContentPresenter.shared.messageNotification("_error_", description: "User Default, username not found", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorInternalError, forced: true)
             return
         }
         guard let password = self.password else {
-            NCContentPresenter.shared.messageNotification("_error_", description: "User Default, password not found", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.ErrorInternalError, forced: true)
+            NCContentPresenter.shared.messageNotification("_error_", description: "User Default, password not found", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorInternalError, forced: true)
             return
         }
         
@@ -86,13 +88,13 @@ class NCAppConfigView: UIViewController {
                     NCManageDatabase.shared.addAccount(account, urlBase: serverUrl, user: username, password: token!)
                     
                     guard let tableAccount = NCManageDatabase.shared.setAccountActive(account) else {
-                        NCContentPresenter.shared.messageNotification("_error_", description: "setAccountActive error", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.ErrorInternalError, forced: true)
+                        NCContentPresenter.shared.messageNotification("_error_", description: "setAccountActive error", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorInternalError, forced: true)
                         self.dismiss(animated: true, completion: nil)
                         return
                     }
                     
                     self.appDelegate.settingAccount(account, urlBase: serverUrl, user: username, userId: tableAccount.userId, password: token!)
-                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
                     
                     self.dismiss(animated: true) {}
                 } else {

+ 17 - 4
iOSClient/Login/NCLogin.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -111,6 +111,16 @@
                             <activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="white" translatesAutoresizingMaskIntoConstraints="NO" id="Kfq-Bg-a0E">
                                 <rect key="frame" x="381" y="176" width="20" height="20"/>
                             </activityIndicatorView>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5lM-dt-8fM">
+                                <rect key="frame" x="182" y="548" width="50" height="50"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="50" id="0RD-Gi-CTv"/>
+                                    <constraint firstAttribute="width" constant="50" id="NuK-Yo-LoT"/>
+                                </constraints>
+                                <connections>
+                                    <action selector="actionCertificate:" destination="yj9-jo-WIn" eventType="touchUpInside" id="Ibx-wC-iEY"/>
+                                </connections>
+                            </button>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6tp-bh-Z9k" userLabel="QRCode">
                                 <rect key="frame" x="182" y="448" width="50" height="50"/>
                                 <constraints>
@@ -141,10 +151,12 @@
                             <constraint firstItem="7q8-rl-x2M" firstAttribute="leading" secondItem="8lf-3Y-f5R" secondAttribute="leading" constant="10" id="bf8-6l-dfs"/>
                             <constraint firstItem="4OF-5u-Hd1" firstAttribute="leading" secondItem="8lf-3Y-f5R" secondAttribute="leading" constant="10" id="e7p-K8-Tt3"/>
                             <constraint firstItem="s9o-RX-XeS" firstAttribute="leading" secondItem="8lf-3Y-f5R" secondAttribute="leading" constant="10" id="gYr-20-hOQ"/>
+                            <constraint firstItem="5lM-dt-8fM" firstAttribute="top" secondItem="6tp-bh-Z9k" secondAttribute="bottom" constant="50" id="i5K-Jt-epF"/>
                             <constraint firstItem="7q8-rl-x2M" firstAttribute="centerY" secondItem="jU7-Iw-XfU" secondAttribute="centerY" id="jhu-Tk-ifA"/>
                             <constraint firstItem="8lf-3Y-f5R" firstAttribute="bottom" secondItem="owR-PS-F32" secondAttribute="bottom" id="kxd-eg-KfO"/>
                             <constraint firstItem="szn-G7-5sK" firstAttribute="top" secondItem="BpI-xK-1SU" secondAttribute="bottom" id="lWz-Yy-NCO"/>
                             <constraint firstItem="8lf-3Y-f5R" firstAttribute="trailing" secondItem="HQd-pF-3cE" secondAttribute="trailing" constant="50" id="mK0-hK-nIb"/>
+                            <constraint firstItem="5lM-dt-8fM" firstAttribute="centerX" secondItem="8lf-3Y-f5R" secondAttribute="centerX" id="mKe-Nn-9dd"/>
                             <constraint firstItem="fhk-o9-J0l" firstAttribute="centerY" secondItem="jU7-Iw-XfU" secondAttribute="centerY" id="mxp-Nw-IAQ"/>
                             <constraint firstItem="HQd-pF-3cE" firstAttribute="leading" secondItem="8lf-3Y-f5R" secondAttribute="leading" constant="50" id="rwA-Qb-mto"/>
                             <constraint firstItem="s9o-RX-XeS" firstAttribute="centerY" secondItem="szn-G7-5sK" secondAttribute="centerY" id="s6D-hp-8Fw"/>
@@ -159,6 +171,7 @@
                     <connections>
                         <outlet property="activity" destination="Kfq-Bg-a0E" id="SqA-zj-Vd6"/>
                         <outlet property="baseUrl" destination="szn-G7-5sK" id="rpO-mh-09O"/>
+                        <outlet property="certificate" destination="5lM-dt-8fM" id="vw6-cH-njm"/>
                         <outlet property="imageBaseUrl" destination="s9o-RX-XeS" id="Q81-S9-1P2"/>
                         <outlet property="imageBrand" destination="BpI-xK-1SU" id="0tB-69-RNs"/>
                         <outlet property="imagePassword" destination="7q8-rl-x2M" id="Cr5-Te-Rkq"/>
@@ -199,7 +212,7 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="uEr-qx-rv2">
-                                <rect key="frame" x="95.5" y="374.5" width="223" height="157"/>
+                                <rect key="frame" x="79" y="389" width="256" height="128"/>
                             </imageView>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="898-PT-7ao">
                                 <rect key="frame" x="10" y="94" width="394" height="20.5"/>
@@ -232,7 +245,7 @@
         <image name="loginPassword" width="25" height="25"/>
         <image name="loginURL" width="25" height="25"/>
         <image name="loginUser" width="25" height="25"/>
-        <image name="logo" width="223" height="157.5"/>
+        <image name="logo" width="256" height="128"/>
         <image name="visiblePassword" width="25" height="25"/>
     </resources>
 </document>

+ 107 - 13
iOSClient/Login/NCLogin.swift

@@ -21,7 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 import NCCommunication
 
 class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
@@ -43,6 +43,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
     @IBOutlet weak var loginModeButton: UIButton!
     
     @IBOutlet weak var qrCode: UIButton!
+    @IBOutlet weak var certificate: UIButton!
 
     enum loginMode {
         case traditional, webFlow
@@ -53,8 +54,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
     var textColor: UIColor = .white
     var textColorOpponent: UIColor = .black
     
-
-    // MARK: - Life Cycle
+    // MARK: - View Life Cycle
 
     override func viewDidLoad() {
         super.viewDidLoad()
@@ -121,12 +121,20 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         // qrcode
         qrCode.setImage(UIImage(named: "qrcode")?.image(color: textColor, size: 100), for: .normal)
         
+        // certificate
+        certificate.setImage(UIImage(named: "certificate")?.image(color: textColor, size: 100), for: .normal)
+        certificate.isHidden = true
+        certificate.isEnabled = false
+        
         if NCManageDatabase.shared.getAccounts()?.count ?? 0 == 0 {
+            
             imageUser.isHidden = true
             user.isHidden = true
             imagePassword.isHidden = true
             password.isHidden = true
+            
         } else {
+            
             imageUser.isHidden = true
             user.isHidden = true
             imagePassword.isHidden = true
@@ -136,6 +144,8 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
             let navigationItemCancel = UIBarButtonItem.init(barButtonSystemItem: .stop, target: self, action: #selector(self.actionCancel))
             navigationItemCancel.tintColor = textColor
             navigationItem.leftBarButtonItem = navigationItemCancel
+            
+            NotificationCenter.default.addObserver(self, selector: #selector(applicationDidEnterBackground), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterApplicationDidEnterBackground), object: nil)
         }
         
         self.navigationController?.navigationBar.setValue(true, forKey: "hidesShadow")
@@ -153,6 +163,13 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         appDelegate.startTimerErrorNetworking()
     }
     
+    // MARK: - NotificationCenter
+
+    @objc func applicationDidEnterBackground() {
+        
+        dismiss(animated: false)
+    }
+    
     // MARK: - TextField
     
     func textFieldShouldReturn(_ textField: UITextField) -> Bool {
@@ -198,7 +215,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                 self.loginButton.isEnabled = true
                 self.activity.stopAnimating()
                 
-                self.standardLogin(urlBase: url, user: username, password: token ?? "", errorCode: errorCode, errorDescription: errorDescription)
+                self.standardLogin(url: url, user: username, password: token ?? "", errorCode: errorCode, errorDescription: errorDescription)
             }
         }
     }
@@ -243,6 +260,48 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         qrCode.scan()
     }
     
+    @IBAction func actionCertificate(_ sender: Any) {
+        
+        let pathsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
+        let fileNameCertificate = pathsDirectory.appendingPathComponent(NCGlobal.shared.certificate).path
+        let directoryCertificate = CCUtility.getDirectoryCerificates()!
+        
+        var host = "cloud.nextcloud.com"
+        if let url = URL(string: NCBrandOptions.shared.loginBaseUrl) {
+            let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false)
+            if let hostComponets = urlComponents?.host {
+                host = hostComponets
+            }
+        }
+            
+        if FileManager.default.fileExists(atPath: fileNameCertificate) {
+            
+            let certificateToPath = directoryCertificate + "/" + host + ".der"
+        
+            if NCUtilityFileSystem.shared.moveFile(atPath: fileNameCertificate, toPath: certificateToPath) {
+                
+                let message = String(format: NSLocalizedString("_certificate_installed_", comment: ""), NCGlobal.shared.certificate)
+                let alertController = UIAlertController(title: "", message: message, preferredStyle: .alert)
+                alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in }))
+                self.present(alertController, animated: true, completion: { })
+                
+            } else {
+                
+                let message = String(format: NSLocalizedString("_copy_failed_", comment: ""), NCGlobal.shared.certificate)
+                let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: message, preferredStyle: .alert)
+                alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in }))
+                self.present(alertController, animated: true, completion: { })
+            }
+            
+        } else {
+            
+            let message = String(format: NSLocalizedString("_certificate_not_found_", comment: ""), NCGlobal.shared.certificate)
+            let alertController = UIAlertController(title: NSLocalizedString("_file_not_found_", comment: ""), message: message, preferredStyle: .alert)
+            alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in }))
+            self.present(alertController, animated: true, completion: { })
+        }
+    }
+    
     // MARK: - Login
 
     func isUrlValid(url: String) {
@@ -254,6 +313,8 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
             
             if errorCode == 0 {
                 
+                NCNetworking.shared.writeCertificate(url: url)
+                
                 NCCommunication.shared.getLoginFlowV2(serverUrl: url) { (token, endpoint, login, errorCode, errorDescription) in
                     
                     self.loginButton.isEnabled = true
@@ -304,7 +365,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                     let alertController = UIAlertController(title: NSLocalizedString("_ssl_certificate_untrusted_", comment: ""), message: NSLocalizedString("_connect_server_anyway_", comment: ""), preferredStyle: .alert)
                                 
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .default, handler: { action in
-                        NCNetworking.shared.writeCertificate(directoryCertificate: CCUtility.getDirectoryCerificates())
+                        NCNetworking.shared.writeCertificate(url: url)
                         self.appDelegate.startTimerErrorNetworking()
                     }))
                     
@@ -312,6 +373,12 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                         self.appDelegate.startTimerErrorNetworking()
                     }))
                     
+                    alertController.addAction(UIAlertAction(title: NSLocalizedString("_certificate_details_", comment: ""), style: .default, handler: { action in
+                        if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() {
+                            self.present(navigationController, animated: true)
+                        }
+                    }))
+                    
                     self.present(alertController, animated: true, completion: {
                         self.appDelegate.timerErrorNetworking?.invalidate()
                     })
@@ -328,18 +395,22 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         }
     }
     
-    func standardLogin(urlBase: String, user: String, password: String, errorCode: Int, errorDescription: String) {
+    func standardLogin(url: String, user: String, password: String, errorCode: Int, errorDescription: String) {
         
         if errorCode == 0 {
             
-            let account = user + " " + urlBase
+            NCNetworking.shared.writeCertificate(url: url)
+            
+            let account = user + " " + url
             
             if NCManageDatabase.shared.getAccounts() == nil {
                 NCUtility.shared.removeAllSettings()
             }
             
+            CCUtility.clearCertificateError(account)
+            
             NCManageDatabase.shared.deleteAccount(account)
-            NCManageDatabase.shared.addAccount(account, urlBase: urlBase, user: user, password: password)
+            NCManageDatabase.shared.addAccount(account, urlBase: url, user: user, password: password)
             
             if let activeAccount = NCManageDatabase.shared.setAccountActive(account) {
                 appDelegate.settingAccount(activeAccount.account, urlBase: activeAccount.urlBase, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account))
@@ -347,7 +418,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
             
             if CCUtility.getIntro() {
                 
-                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
                 self.dismiss(animated: true)
                 
             } else {
@@ -358,18 +429,41 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                     
                     let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
                     viewController?.modalPresentationStyle = .fullScreen
-                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
                     self.appDelegate.window?.rootViewController = viewController
                     self.appDelegate.window?.makeKey()
                     
                 } else {
                     
-                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
                     self.dismiss(animated: true)
                 }
             }
+        
+        } else if errorCode == NSURLErrorServerCertificateUntrusted {
+            
+            let alertController = UIAlertController(title: NSLocalizedString("_ssl_certificate_untrusted_", comment: ""), message: NSLocalizedString("_connect_server_anyway_", comment: ""), preferredStyle: .alert)
+                        
+            alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .default, handler: { action in
+                NCNetworking.shared.writeCertificate(url: url)
+                self.appDelegate.startTimerErrorNetworking()
+            }))
             
-        } else if errorCode != NSURLErrorServerCertificateUntrusted {
+            alertController.addAction(UIAlertAction(title: NSLocalizedString("_no_", comment: ""), style: .default, handler: { action in
+                self.appDelegate.startTimerErrorNetworking()
+            }))
+            
+            alertController.addAction(UIAlertAction(title: NSLocalizedString("_certificate_details_", comment: ""), style: .default, handler: { action in
+                if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() {
+                    self.present(navigationController, animated: true)
+                }
+            }))
+            
+            self.present(alertController, animated: true, completion: {
+                self.appDelegate.timerErrorNetworking?.invalidate()
+            })
+            
+        } else {
             
             let message = NSLocalizedString("_not_possible_connect_to_server_", comment: "") + ".\n" + errorDescription
             let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: message, preferredStyle: .alert)
@@ -408,7 +502,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                     self.activity.stopAnimating()
                     self.loginButton.isEnabled = true
                     
-                    self.standardLogin(urlBase: urlBase, user: user, password: password, errorCode: errorCode, errorDescription: errorDescription)
+                    self.standardLogin(url: urlBase, user: user, password: password, errorCode: errorCode, errorDescription: errorDescription)
                 }
             }
         }

+ 1 - 1
iOSClient/Login/NCLoginQRCode.swift

@@ -21,7 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 import QRCodeReader
 
 @objc public protocol NCLoginQRCodeDelegate {

+ 16 - 11
iOSClient/Login/NCLoginWeb.swift

@@ -21,7 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 import WebKit
 import NCCommunication
 import FloatingPanel
@@ -39,8 +39,8 @@ class NCLoginWeb: UIViewController {
     @objc var loginFlowV2Endpoint = ""
     @objc var loginFlowV2Login = ""
     
-    // MARK: - Life Cycle
-    
+    // MARK: - View Life Cycle
+
     override func viewDidLoad() {
         super.viewDidLoad()
         
@@ -51,7 +51,7 @@ class NCLoginWeb: UIViewController {
         }
         
         if accountCount > 0 {
-            navigationItem.rightBarButtonItem = UIBarButtonItem.init(image: UIImage(named: "users")!.image(color: NCBrandColor.shared.textView, size: 35), style: .plain, target: self, action:  #selector(self.changeUser(sender:)))
+            navigationItem.rightBarButtonItem = UIBarButtonItem.init(image: UIImage(named: "users")!.image(color: NCBrandColor.shared.label, size: 35), style: .plain, target: self, action:  #selector(self.changeUser(sender:)))
         }
         
         let config = WKWebViewConfiguration()
@@ -84,7 +84,7 @@ class NCLoginWeb: UIViewController {
         if let url = URL(string: urlBase) {
             loadWebPage(webView: webView!, url: url)
         } else {
-            NCContentPresenter.shared.messageNotification("_error_", description: "_login_url_error_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.ErrorInternalError, forced: true)
+            NCContentPresenter.shared.messageNotification("_error_", description: "_login_url_error_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorInternalError, forced: true)
         }
     }
     
@@ -245,9 +245,6 @@ extension NCLoginWeb: WKNavigationDelegate {
         
         var urlBase = server
         
-        // NO account found, clear all
-        if NCManageDatabase.shared.getAccounts() == nil { NCUtility.shared.removeAllSettings() }
-            
         // Normalized
         if (urlBase.last == "/") {
             urlBase = String(urlBase.dropLast())
@@ -255,6 +252,14 @@ extension NCLoginWeb: WKNavigationDelegate {
         
         // Create account
         let account: String = "\(username) \(urlBase)"
+        
+        // NO account found, clear all
+        if NCManageDatabase.shared.getAccounts() == nil {
+            NCUtility.shared.removeAllSettings()
+        }
+        
+        // Clear certificate error 
+        CCUtility.clearCertificateError(account)
 
         // Add new account
         NCManageDatabase.shared.deleteAccount(account)
@@ -269,7 +274,7 @@ extension NCLoginWeb: WKNavigationDelegate {
             
         if (CCUtility.getIntro()) {
             
-            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
             self.dismiss(animated: true)
                 
         } else {
@@ -278,7 +283,7 @@ extension NCLoginWeb: WKNavigationDelegate {
             if (self.presentingViewController == nil) {
                 if let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController() {
                     viewController.modalPresentationStyle = .fullScreen
-                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+                    NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
                     viewController.view.alpha = 0
                     appDelegate.window?.rootViewController = viewController
                     appDelegate.window?.makeKeyAndVisible()
@@ -287,7 +292,7 @@ extension NCLoginWeb: WKNavigationDelegate {
                     }
                 }
             } else {
-                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitializeMain)
+                NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterInitialize)
                 self.dismiss(animated: true)
             }
         }

+ 0 - 60
iOSClient/Main/ActionSheetHeaderView/NCActionSheetHeader.swift

@@ -1,60 +0,0 @@
-//
-//  NCActionSheetHeader.swift
-//  Nextcloud
-//
-//  Created by Marino Faggiana on 08/11/2018.
-//  Copyright © 2018 Marino Faggiana. All rights reserved.
-//
-//  Author Marino Faggiana <marino.faggiana@nextcloud.com>
-//
-//  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 Foundation
-
-class NCActionSheetHeader: NSObject {
-    
-    static let shared: NCActionSheetHeader = {
-        let instance = NCActionSheetHeader()
-        return instance
-    }()
-    
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-
-    func actionSheetHeader(isDirectory: Bool, iconName: String, ocId: String, etag: String, text: String) -> UIView? {
-        
-        var image: UIImage?
-        
-        // Header
-        if isDirectory {
-            image = UIImage.init(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width)
-        } else if iconName.count > 0 {
-            image = UIImage.init(named: iconName)
-        } else {
-            image = UIImage.init(named: "file")
-        }
-        if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconOcId(ocId, etag: etag)) {
-            image = UIImage.init(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(ocId, etag: etag))
-        }
-        
-        let headerView = UINib(nibName: "NCActionSheetHeaderView", bundle: nil).instantiate(withOwner: self, options: nil).first as! NCActionSheetHeaderView
-        
-        headerView.backgroundColor = NCBrandColor.shared.backgroundForm
-        headerView.imageItem.image = image
-        headerView.label.text = text
-        headerView.label.textColor = NCBrandColor.shared.icon
-        
-        return headerView
-    }
-}

+ 0 - 51
iOSClient/Main/ActionSheetHeaderView/NCActionSheetHeaderView.xib

@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
-    <device id="retina5_5" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
-    <dependencies>
-        <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
-        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
-        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-        <view contentMode="scaleToFill" id="I6b-nN-xlb" customClass="NCActionSheetHeaderView" customModule="Nextcloud" customModuleProvider="target">
-            <rect key="frame" x="0.0" y="0.0" width="414" height="50"/>
-            <autoresizingMask key="autoresizingMask"/>
-            <subviews>
-                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="lfq-lr-NgS" userLabel="ImageItem">
-                    <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
-                    <constraints>
-                        <constraint firstAttribute="height" constant="50" id="LyU-cM-aSJ"/>
-                        <constraint firstAttribute="width" constant="50" id="dY1-pJ-pdP"/>
-                    </constraints>
-                </imageView>
-                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yAB-e1-3vF">
-                    <rect key="frame" x="55" y="0.0" width="354" height="50"/>
-                    <fontDescription key="fontDescription" type="system" pointSize="14"/>
-                    <nil key="textColor"/>
-                    <nil key="highlightedColor"/>
-                </label>
-            </subviews>
-            <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-            <constraints>
-                <constraint firstItem="yAB-e1-3vF" firstAttribute="leading" secondItem="lfq-lr-NgS" secondAttribute="trailing" constant="5" id="0ZQ-29-0WG"/>
-                <constraint firstItem="2A6-rU-2Mc" firstAttribute="bottom" secondItem="yAB-e1-3vF" secondAttribute="bottom" id="BjK-gV-vSx"/>
-                <constraint firstItem="lfq-lr-NgS" firstAttribute="leading" secondItem="2A6-rU-2Mc" secondAttribute="leading" id="cMS-FO-o0J"/>
-                <constraint firstItem="yAB-e1-3vF" firstAttribute="top" secondItem="2A6-rU-2Mc" secondAttribute="top" id="gFc-7X-Z4w"/>
-                <constraint firstItem="lfq-lr-NgS" firstAttribute="top" secondItem="2A6-rU-2Mc" secondAttribute="top" id="nlU-7A-uMz"/>
-                <constraint firstItem="2A6-rU-2Mc" firstAttribute="trailing" secondItem="yAB-e1-3vF" secondAttribute="trailing" constant="5" id="zl1-OY-Erp"/>
-            </constraints>
-            <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
-            <viewLayoutGuide key="safeArea" id="2A6-rU-2Mc"/>
-            <connections>
-                <outlet property="imageItem" destination="lfq-lr-NgS" id="jW9-9z-oNq"/>
-                <outlet property="label" destination="yAB-e1-3vF" id="SiI-G5-9og"/>
-            </connections>
-            <point key="canvasLocation" x="-479.71014492753625" y="196.46739130434784"/>
-        </view>
-    </objects>
-</document>

+ 42 - 28
iOSClient/Main/AudioRecorder/NCAudioRecorderViewController.swift

@@ -24,7 +24,6 @@
 //  Based on code of Venkat Kukunuru
 //  --------------------------------
 
-import Foundation
 import UIKit
 import AVFoundation
 import QuartzCore
@@ -46,38 +45,39 @@ class NCAudioRecorderViewController: UIViewController , NCAudioRecorderDelegate
     @IBOutlet weak var startStopLabel: UILabel!
     @IBOutlet weak var voiceRecordHUD: VoiceRecordHUD!
     
-    // MARK: View Life Cycle
-    
+    // MARK: - View Life Cycle
+
     override func viewDidLoad() {
         super.viewDidLoad()
+        
+        voiceRecordHUD.update(0.0)
+        durationLabel.text = ""
+        startStopLabel.text = NSLocalizedString("_voice_memo_start_", comment: "")
+        
+        changeTheming()
     }
     
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
+    }
+    
+    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
+        super.traitCollectionDidChange(previousTraitCollection)
         
-        contentContainerView.backgroundColor = UIColor.lightGray
-        voiceRecordHUD.update(0.0)
-        voiceRecordHUD.fillColor = UIColor.green
-        durationLabel.text = ""
-        startStopLabel.text = NSLocalizedString("_voice_memo_start_", comment: "")
+        changeTheming()
     }
     
-    func createRecorder(fileName: String) {
+    // MARK: - Colors
+    
+    func changeTheming() {
         
-        self.fileName = fileName
-        recording = NCAudioRecorder(to: fileName)
-        recording.delegate = self
-
-        DispatchQueue.global().async {
-            // Background thread
-            do {
-                try self.recording.prepare()
-            } catch {
-                print(error)
-            }
-        }
+        view.backgroundColor = .clear
+        contentContainerView.backgroundColor = UIColor.lightGray
+        voiceRecordHUD.fillColor = UIColor.green
     }
     
+    // MARK: - Action
+    
     @IBAction func touchViewController() {
         
         if recording.state == .record {
@@ -112,6 +112,24 @@ class NCAudioRecorderViewController: UIViewController , NCAudioRecorderDelegate
         }
     }
     
+    // MARK: - Code
+    
+    func createRecorder(fileName: String) {
+        
+        self.fileName = fileName
+        recording = NCAudioRecorder(to: fileName)
+        recording.delegate = self
+
+        DispatchQueue.global().async {
+            // Background thread
+            do {
+                try self.recording.prepare()
+            } catch {
+                print(error)
+            }
+        }
+    }
+    
     func audioMeterDidUpdate(_ db: Float) {
         
         //print("db level: %f", db)
@@ -194,10 +212,7 @@ open class NCAudioRecorder : NSObject {
         if recorder == nil {
             try prepare()
         }
-        
-        try session.setCategory(.playAndRecord, mode: .default)
-        try session.overrideOutputAudioPort(AVAudioSession.PortOverride.speaker)
-        
+                
         recorder?.record()
         state = .record
         
@@ -211,9 +226,6 @@ open class NCAudioRecorder : NSObject {
             try prepare()
         }
         
-        try session.setCategory(.playback, mode: .default)
-        try AVAudioSession.sharedInstance().setActive(true)
-
         player = try AVAudioPlayer(contentsOf: url)
         player?.prepareToPlay()
 
@@ -276,6 +288,8 @@ class VoiceRecordHUD: UIView {
         }
     }
     
+    // MARK: - View Life Cycle
+
     override init(frame: CGRect) {
         super.init(frame: frame)
         image = UIImage(named: "microphone")

File diff suppressed because it is too large
+ 345 - 208
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift


+ 9 - 1
iOSClient/Main/Collection Common/NCGridCell.swift

@@ -21,7 +21,6 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
 import UIKit
 
 class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCellProtocol {
@@ -129,6 +128,13 @@ protocol NCGridCellDelegate {
     func longPressGridItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer)
 }
 
+// optional func
+extension NCGridCellDelegate {
+    func tapMoreGridItem(with objectId: String, namedButtonMore: String, image: UIImage?, sender: Any) {}
+    func longPressMoreGridItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) {}
+    func longPressGridItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {}
+}
+
 // MARK: - Grid Layout
 
 class NCGridLayout: UICollectionViewFlowLayout {
@@ -138,6 +144,8 @@ class NCGridLayout: UICollectionViewFlowLayout {
     var itemForLine: CGFloat = 3
     var itemWidthDefault: CGFloat = 120
 
+    // MARK: - View Life Cycle
+
     override init() {
         super.init()
         

+ 2 - 3
iOSClient/Main/Collection Common/NCGridCell.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -64,7 +64,6 @@
                             <rect key="frame" x="0.0" y="0.0" width="220" height="220"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         </view>
-                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <blurEffect style="extraLight"/>
                     </visualEffectView>
                     <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="DHy-Up-3Bh" userLabel="imageSelect">

+ 17 - 6
iOSClient/Main/Collection Common/NCListCell.swift

@@ -21,7 +21,6 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
 import UIKit
 
 class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCellProtocol {
@@ -47,7 +46,8 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
     @IBOutlet weak var progressView: UIProgressView!
     
     @IBOutlet weak var separator: UIView!
-    
+    @IBOutlet weak var separatorHeightConstraint: NSLayoutConstraint!
+
     var filePreviewImageView : UIImageView {
         get{
          return imageItem
@@ -79,7 +79,10 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
         longPressedGestureMore.minimumPressDuration = 0.5
         longPressedGestureMore.delegate = self
         longPressedGestureMore.delaysTouchesBegan = true
-        buttonMore.addGestureRecognizer(longPressedGestureMore)        
+        buttonMore.addGestureRecognizer(longPressedGestureMore)
+        
+        separator.backgroundColor = NCBrandColor.shared.separator
+        separatorHeightConstraint.constant = 0.5
     }
     
     override func prepareForReuse() {
@@ -132,14 +135,12 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
     func selected(_ status: Bool) {
         if status {
             imageSelect.image = NCBrandColor.cacheImages.checkedYes
-            
             let blurEffect = UIBlurEffect(style: .extraLight)
             let blurEffectView = UIVisualEffectView(effect: blurEffect)
             blurEffectView.frame = self.bounds
             blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
-            blurEffectView.backgroundColor = NCBrandColor.shared.brandElement.withAlphaComponent(0.2)
+            blurEffectView.backgroundColor = .lightGray
             backgroundView = blurEffectView
-            
             separator.isHidden = true
         } else {
             imageSelect.image = NCBrandColor.cacheImages.checkedNo
@@ -156,12 +157,22 @@ protocol NCListCellDelegate {
     func longPressListItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer)
 }
 
+// optional func
+extension NCListCellDelegate {
+    func tapShareListItem(with objectId: String, sender: Any) {}
+    func tapMoreListItem(with objectId: String, namedButtonMore: String, image: UIImage?, sender: Any) {}
+    func longPressMoreListItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) {}
+    func longPressListItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {}
+}
+
 // MARK: - List Layout
 
 class NCListLayout: UICollectionViewFlowLayout {
     
     var itemHeight: CGFloat = 60
     
+    // MARK: - View Life Cycle
+
     override init() {
         super.init()
         

+ 4 - 3
iOSClient/Main/Collection Common/NCListCell.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -96,7 +96,7 @@
                         <rect key="frame" x="567.5" y="17.5" width="25" height="25"/>
                         <constraints>
                             <constraint firstAttribute="width" constant="25" id="05P-NL-pd8"/>
-                            <constraint firstAttribute="height" constant="25" id="Jet-eo-x1M" userLabel="height = 20"/>
+                            <constraint firstAttribute="height" constant="25" id="Jet-eo-x1M"/>
                         </constraints>
                     </imageView>
                     <progressView hidden="YES" opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="m2p-oJ-j15">
@@ -161,6 +161,7 @@
                 <outlet property="labelTitle" destination="UtT-L6-mgW" id="Xv6-zM-2v1"/>
                 <outlet property="progressView" destination="m2p-oJ-j15" id="yFv-KS-nEy"/>
                 <outlet property="separator" destination="Egg-cb-EhZ" id="uhq-Nc-z8K"/>
+                <outlet property="separatorHeightConstraint" destination="G5S-67-boG" id="B6g-qe-MTb"/>
             </connections>
             <point key="canvasLocation" x="97.599999999999994" y="129.53523238380811"/>
         </collectionViewCell>

+ 51 - 44
iOSClient/Main/Create cloud/NCCreateFormUploadAssets.swift

@@ -21,7 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 import Queuer
 
 protocol createFormUploadAssetsDelegate {
@@ -41,6 +41,10 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
     let targetSizeImagePreview = CGSize(width:100, height: 100)
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     
+    var cellBackgoundColor = NCBrandColor.shared.secondarySystemGroupedBackground
+        
+    // MARK: - View Life Cycle
+
     convenience init(serverUrl: String, assets: [PHAsset], cryptated: Bool, session: String, delegate: createFormUploadAssetsDelegate?) {
         
         self.init()
@@ -66,8 +70,6 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         requestOptions.isSynchronous = true
     }
     
-    // MARK: - View Life Cycle
-    
     override func viewDidLoad() {
         
         super.viewDidLoad()
@@ -85,9 +87,10 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
             })
         }
         
-        NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
-
         changeTheming()
+        
+        initializeForm()
+        reloadForm()
     }
     
     override func viewWillDisappear(_ animated: Bool)
@@ -97,12 +100,21 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         self.delegate?.dismissFormUploadAssets()
     }
     
-    @objc func changeTheming() {
-        view.backgroundColor = NCBrandColor.shared.backgroundForm
-        tableView.backgroundColor = NCBrandColor.shared.backgroundForm
+    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
+        super.traitCollectionDidChange(previousTraitCollection)
+        
+        changeTheming()
+    }
+    
+    // MARK: - Theming
+    
+    func changeTheming() {
+        
+        view.backgroundColor = NCBrandColor.shared.systemGroupedBackground
+        tableView.backgroundColor = NCBrandColor.shared.systemGroupedBackground
+        cellBackgoundColor = NCBrandColor.shared.secondarySystemGroupedBackground
+        
         tableView.reloadData()
-        initializeForm()
-        self.reloadForm()
     }
     
     //MARK: XLForm
@@ -122,29 +134,29 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         
         row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: self.titleServerUrl)
         row.action.formSelector = #selector(changeDestinationFolder(_:))
-        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
+        row.cellConfig["backgroundColor"] = cellBackgoundColor
 
         row.cellConfig["imageView.image"] = UIImage(named: "folder")!.image(color: NCBrandColor.shared.brandElement, size: 25)
         row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.label
         
         section.addFormRow(row)
         
         // User folder Autoupload
         row = XLFormRowDescriptor(tag: "useFolderAutoUpload", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_use_folder_auto_upload_", comment: ""))
         row.value = 0
-        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
+        row.cellConfig["backgroundColor"] = cellBackgoundColor
 
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.label
         
         section.addFormRow(row)
         
         // Use Sub folder
         row = XLFormRowDescriptor(tag: "useSubFolder", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_autoupload_create_subfolder_", comment: ""))
-        let tableAccount = NCManageDatabase.shared.getAccountActive()
-        if tableAccount?.autoUploadCreateSubfolder == true {
+        let activeAccount = NCManageDatabase.shared.getActiveAccount()
+        if activeAccount?.autoUploadCreateSubfolder == true {
             row.value = 1
         } else {
             row.value = 0
@@ -152,7 +164,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         row.hidden = "$\("useFolderAutoUpload") == 0"
         
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.label
         
         section.addFormRow(row)
 
@@ -165,10 +177,10 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         
         row = XLFormRowDescriptor(tag: "maintainOriginalFileName", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_maintain_original_filename_", comment: ""))
         row.value = CCUtility.getOriginalFileName(NCGlobal.shared.keyFileNameOriginal)
-        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
+        row.cellConfig["backgroundColor"] = cellBackgoundColor
 
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.label
         
         section.addFormRow(row)
         
@@ -177,10 +189,10 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         row = XLFormRowDescriptor(tag: "addFileNameType", rowType: XLFormRowDescriptorTypeBooleanSwitch, title: NSLocalizedString("_add_filenametype_", comment: ""))
         row.value = CCUtility.getFileNameType(NCGlobal.shared.keyFileNameType)
         row.hidden = "$\("maintainOriginalFileName") == 1"
-        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
+        row.cellConfig["backgroundColor"] = cellBackgoundColor
 
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.label
         
         section.addFormRow(row)
         
@@ -189,20 +201,20 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_filename_", comment: ""))
         form.addFormSection(section)
         
-        row = XLFormRowDescriptor(tag: "maskFileName", rowType: XLFormRowDescriptorTypeAccount, title: (NSLocalizedString("_filename_", comment: "")))
+        row = XLFormRowDescriptor(tag: "maskFileName", rowType: XLFormRowDescriptorTypeText, title: (NSLocalizedString("_filename_", comment: "")))
         let fileNameMask : String = CCUtility.getFileNameMask(NCGlobal.shared.keyFileNameMask)
         if fileNameMask.count > 0 {
             row.value = fileNameMask
         }
         row.hidden = "$\("maintainOriginalFileName") == 1"
-        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
+        row.cellConfig["backgroundColor"] = cellBackgoundColor
 
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.label
         
         row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
         row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textField.textColor"] = NCBrandColor.shared.textView
+        row.cellConfig["textField.textColor"] = NCBrandColor.shared.label
 
         section.addFormRow(row)
         
@@ -211,11 +223,11 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         row = XLFormRowDescriptor(tag: "previewFileName", rowType: XLFormRowDescriptorTypeTextView, title: "")
         row.height = 180
         row.disabled = true
-        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
+        row.cellConfig["backgroundColor"] = cellBackgoundColor
 
-        row.cellConfig["textView.backgroundColor"] = NCBrandColor.shared.backgroundForm
+        row.cellConfig["textView.backgroundColor"] = cellBackgoundColor
         row.cellConfig["textView.font"] = UIFont.systemFont(ofSize: 14.0)
-        row.cellConfig["textView.textColor"] = NCBrandColor.shared.textView
+        row.cellConfig["textView.textColor"] = NCBrandColor.shared.label
 
         section.addFormRow(row)
         
@@ -277,7 +289,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
                     
                     self.reloadFormRow(formRow)
                     
-                    NCContentPresenter.shared.messageNotification("_info_", description: "_forbidden_characters_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.ErrorCharactersForbidden, forced: true)
+                    NCContentPresenter.shared.messageNotification("_info_", description: "_forbidden_characters_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorCharactersForbidden, forced: true)
                 }
             }
             
@@ -301,8 +313,8 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
     }
     
     // MARK: - Action
-    
-    func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], buttonType: String, overwrite: Bool) {
+         
+    func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], overwrite: Bool, copy: Bool, move: Bool) {
         
         if serverUrl != nil {
             
@@ -365,7 +377,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
             let autoUploadPath = NCManageDatabase.shared.getAccountAutoUploadPath(urlBase: self.appDelegate.urlBase, account: self.appDelegate.account)
             if autoUploadPath == self.serverUrl {
                 if !NCNetworking.shared.createFolder(assets: self.assets, selector: NCGlobal.shared.selectorUploadFile, useSubFolder: useSubFolder, account: self.appDelegate.account, urlBase: self.appDelegate.urlBase) {
-                    NCContentPresenter.shared.messageNotification("_error_", description: "_error_createsubfolders_upload_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.ErrorInternalError, forced: true)
+                    NCContentPresenter.shared.messageNotification("_error_", description: "_error_createsubfolders_upload_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: NCGlobal.shared.errorInternalError, forced: true)
                     return
                 }
             }
@@ -374,7 +386,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
                     
                 var serverUrl = self.serverUrl
                 var livePhoto: Bool = false
-                let fileName = CCUtility.createFileName(asset.value(forKey: "filename") as? String, fileDate: asset.creationDate, fileType: asset.mediaType, keyFileName: NCGlobal.shared.keyFileNameMask, keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal)!
+                let fileName = CCUtility.createFileName(asset.value(forKey: "filename") as? String, fileDate: asset.creationDate, fileType: asset.mediaType, keyFileName: NCGlobal.shared.keyFileNameMask, keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal, forcedNewFileName: false)!
                 let assetDate = asset.creationDate ?? Date()
                 let dateFormatter = DateFormatter()
                 
@@ -401,7 +413,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
                     continue
                 }
                 
-                let metadataForUpload = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, fileName: fileName, fileNameView: fileName, ocId: NSUUID().uuidString, serverUrl: serverUrl, urlBase: self.appDelegate.urlBase, url: "", contentType: "", livePhoto: livePhoto, chunk: false)
+                let metadataForUpload = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, fileName: fileName, fileNameView: fileName, ocId: NSUUID().uuidString, serverUrl: serverUrl, urlBase: self.appDelegate.urlBase, url: "", contentType: "", livePhoto: livePhoto)
                 
                 metadataForUpload.assetLocalIdentifier = asset.localIdentifier
                 metadataForUpload.session = self.session
@@ -419,7 +431,7 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
                     CCUtility.extractLivePhotoAsset(asset, filePath: filePath) { (url) in
                         if let url = url {
                             let fileSize = NCUtilityFileSystem.shared.getFileSize(filePath: url.path)
-                            let metadataMOVForUpload = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, fileName: fileNameMove, fileNameView: fileNameMove, ocId:ocId, serverUrl: serverUrl, urlBase: self.appDelegate.urlBase, url: "", contentType: "", livePhoto: livePhoto, chunk: false)
+                            let metadataMOVForUpload = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, fileName: fileNameMove, fileNameView: fileNameMove, ocId:ocId, serverUrl: serverUrl, urlBase: self.appDelegate.urlBase, url: "", contentType: "", livePhoto: livePhoto)
 
                             metadataForUpload.livePhoto = true
                             metadataMOVForUpload.livePhoto = true
@@ -495,18 +507,18 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
                 CCUtility.setFileNameMask(valueRename, key: NCGlobal.shared.keyFileNameMask)
                 self.form.delegate = self
                 
-                returnString = CCUtility.createFileName(asset.value(forKey: "filename") as! String?, fileDate: asset.creationDate, fileType: asset.mediaType, keyFileName: NCGlobal.shared.keyFileNameMask, keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal)
+                returnString = CCUtility.createFileName(asset.value(forKey: "filename") as! String?, fileDate: asset.creationDate, fileType: asset.mediaType, keyFileName: NCGlobal.shared.keyFileNameMask, keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal, forcedNewFileName: false)
                 
             } else {
                 
                 CCUtility.setFileNameMask("", key: NCGlobal.shared.keyFileNameMask)
-                returnString = CCUtility.createFileName(asset.value(forKey: "filename") as! String?, fileDate: asset.creationDate, fileType: asset.mediaType, keyFileName: nil, keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal)
+                returnString = CCUtility.createFileName(asset.value(forKey: "filename") as! String?, fileDate: asset.creationDate, fileType: asset.mediaType, keyFileName: nil, keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal, forcedNewFileName: false)
             }
             
         } else {
             
             CCUtility.setFileNameMask("", key: NCGlobal.shared.keyFileNameMask)
-            returnString = CCUtility.createFileName(asset.value(forKey: "filename") as! String?, fileDate: asset.creationDate, fileType: asset.mediaType, keyFileName: nil, keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal)
+            returnString = CCUtility.createFileName(asset.value(forKey: "filename") as! String?, fileDate: asset.creationDate, fileType: asset.mediaType, keyFileName: nil, keyFileNameType: NCGlobal.shared.keyFileNameType, keyFileNameOriginal: NCGlobal.shared.keyFileNameOriginal, forcedNewFileName: false)
         }
         
         return String(format: NSLocalizedString("_preview_filename_", comment: ""), "MM, MMM, DD, YY, YYYY, HH, hh, mm, ss, ampm") + ":" + "\n\n" + returnString
@@ -521,14 +533,9 @@ class NCCreateFormUploadAssets: XLFormViewController, NCSelectDelegate {
         let viewController = navigationController.topViewController as! NCSelect
         
         viewController.delegate = self
-        viewController.hideButtonCreateFolder = false
+        viewController.typeOfCommandView = .selectCreateFolder
         viewController.includeDirectoryE2EEncryption = true
-        viewController.includeImages = false
-        viewController.selectFile = false
-        viewController.titleButtonDone = NSLocalizedString("_select_", comment: "")
-        viewController.type = ""
         
-        navigationController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
         self.present(navigationController, animated: true, completion: nil)
     }
 }

+ 28 - 12
iOSClient/Main/Create cloud/NCCreateFormUploadConflict.storyboard

@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="30l-Wp-khL">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="30l-Wp-khL">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -59,7 +60,7 @@
                                         <nil key="highlightedColor"/>
                                     </label>
                                 </subviews>
-                                <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
+                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                                 <constraints>
                                     <constraint firstAttribute="trailing" secondItem="3Tf-oD-aTF" secondAttribute="trailing" constant="5" id="0gO-Y8-9Dl"/>
                                     <constraint firstAttribute="trailing" secondItem="ge9-Fi-Rb1" secondAttribute="trailing" constant="5" id="AkQ-ni-sBE"/>
@@ -75,7 +76,7 @@
                             </view>
                             <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="wkN-gS-XKZ">
                                 <rect key="frame" x="10" y="257.5" width="394" height="534.5"/>
-                                <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
+                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                                 <connections>
                                     <outlet property="dataSource" destination="30l-Wp-khL" id="TVO-SU-fFp"/>
                                     <outlet property="delegate" destination="30l-Wp-khL" id="Qzt-sk-KEh"/>
@@ -84,35 +85,37 @@
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Fow-JU-J8L">
                                 <rect key="frame" x="10" y="802" width="394" height="50"/>
                                 <subviews>
-                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5Nf-YT-2uq">
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5Nf-YT-2uq">
                                         <rect key="frame" x="10" y="5" width="120" height="40"/>
+                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                         <constraints>
                                             <constraint firstAttribute="width" constant="120" id="6Qu-df-wR9"/>
                                             <constraint firstAttribute="height" constant="40" id="dYv-Ox-31e"/>
                                         </constraints>
                                         <state key="normal" title="Cancel">
-                                            <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                            <color key="titleColor" systemColor="labelColor"/>
                                         </state>
                                         <connections>
                                             <action selector="buttonCancelTouch:" destination="30l-Wp-khL" eventType="touchUpInside" id="k3H-hT-Lbm"/>
                                         </connections>
                                     </button>
-                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RU9-v6-zSl">
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RU9-v6-zSl">
                                         <rect key="frame" x="264" y="5" width="120" height="40"/>
+                                        <color key="backgroundColor" systemColor="systemGray4Color"/>
                                         <constraints>
                                             <constraint firstAttribute="width" constant="120" id="WPF-n7-YZM"/>
                                             <constraint firstAttribute="height" constant="40" id="tQn-bn-hx6"/>
                                         </constraints>
-                                        <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                         <state key="normal" title="Continue">
-                                            <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                            <color key="titleColor" systemColor="labelColor"/>
                                         </state>
                                         <connections>
                                             <action selector="buttonContinueTouch:" destination="30l-Wp-khL" eventType="touchUpInside" id="iQq-LC-PSc"/>
                                         </connections>
                                     </button>
                                 </subviews>
-                                <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
+                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                                 <constraints>
                                     <constraint firstItem="5Nf-YT-2uq" firstAttribute="leading" secondItem="Fow-JU-J8L" secondAttribute="leading" constant="10" id="20E-20-aTP"/>
                                     <constraint firstAttribute="trailing" secondItem="RU9-v6-zSl" secondAttribute="trailing" constant="10" id="VOl-Qh-Nkm"/>
@@ -122,7 +125,8 @@
                                 </constraints>
                             </view>
                         </subviews>
-                        <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
+                        <viewLayoutGuide key="safeArea" id="pSm-Za-OgF"/>
+                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                         <constraints>
                             <constraint firstItem="amb-pM-6dC" firstAttribute="leading" secondItem="pSm-Za-OgF" secondAttribute="leading" constant="10" id="4WR-mh-3fp"/>
                             <constraint firstItem="H7Y-Nu-nJ3" firstAttribute="leading" secondItem="pSm-Za-OgF" secondAttribute="leading" constant="10" id="809-bM-vkE"/>
@@ -142,7 +146,6 @@
                             <constraint firstItem="bXc-v3-Lun" firstAttribute="leading" secondItem="pSm-Za-OgF" secondAttribute="leading" constant="10" id="nv3-xM-qib"/>
                             <constraint firstItem="pSm-Za-OgF" firstAttribute="trailing" secondItem="amb-pM-6dC" secondAttribute="trailing" constant="10" id="x1J-AV-BoL"/>
                         </constraints>
-                        <viewLayoutGuide key="safeArea" id="pSm-Za-OgF"/>
                     </view>
                     <connections>
                         <outlet property="buttonCancel" destination="5Nf-YT-2uq" id="cvi-cr-h7O"/>
@@ -154,6 +157,8 @@
                         <outlet property="switchAlreadyExistingFiles" destination="08D-oc-nWS" id="VxI-9Q-9YY"/>
                         <outlet property="switchNewFiles" destination="ge9-Fi-Rb1" id="zy1-W2-UN8"/>
                         <outlet property="tableView" destination="wkN-gS-XKZ" id="rME-eq-aos"/>
+                        <outlet property="viewButton" destination="Fow-JU-J8L" id="bvK-IT-alH"/>
+                        <outlet property="viewSwitch" destination="qry-YF-g1N" id="OLz-XT-dMC"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="9m8-uR-gEZ" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
@@ -161,4 +166,15 @@
             <point key="canvasLocation" x="113.04347826086958" y="99.776785714285708"/>
         </scene>
     </scenes>
+    <resources>
+        <systemColor name="labelColor">
+            <color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
+        <systemColor name="systemBackgroundColor">
+            <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
+        <systemColor name="systemGray4Color">
+            <color red="0.81960784313725488" green="0.81960784313725488" blue="0.83921568627450982" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
+    </resources>
 </document>

+ 46 - 34
iOSClient/Main/Create cloud/NCCreateFormUploadConflict.swift

@@ -21,7 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 
 @objc protocol NCCreateFormUploadConflictDelegate {
     @objc func dismissCreateFormUploadConflict(metadatas: [tableMetadata]?)
@@ -36,6 +36,7 @@ extension NCCreateFormUploadConflictDelegate {
     @IBOutlet weak var labelTitle: UILabel!
     @IBOutlet weak var labelSubTitle: UILabel!
 
+    @IBOutlet weak var viewSwitch: UIView!
     @IBOutlet weak var switchNewFiles: UISwitch!
     @IBOutlet weak var switchAlreadyExistingFiles: UISwitch!
 
@@ -44,6 +45,7 @@ extension NCCreateFormUploadConflictDelegate {
 
     @IBOutlet weak var tableView: UITableView!
 
+    @IBOutlet weak var viewButton: UIView!
     @IBOutlet weak var buttonCancel: UIButton!
     @IBOutlet weak var buttonContinue: UIButton!
     
@@ -60,8 +62,8 @@ extension NCCreateFormUploadConflictDelegate {
     var metadatasConflictNewFiles: [String] = []
     var metadatasConflictAlreadyExistingFiles: [String] = []
     var fileNamesPath: [String: String] = [:]
-
-    // MARK: - Cicle
+    
+    // MARK: - View Life Cycle
 
     @objc required init?(coder aDecoder: NSCoder) {
         self.metadatasNOConflict = []
@@ -98,14 +100,29 @@ extension NCCreateFormUploadConflictDelegate {
         buttonCancel.layer.cornerRadius = 20
         buttonCancel.layer.masksToBounds = true
         buttonCancel.setTitle(NSLocalizedString("_cancel_", comment: ""), for: .normal)
-        buttonCancel.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.5).cgColor
         
         buttonContinue.layer.cornerRadius = 20
         buttonContinue.layer.masksToBounds = true
         buttonContinue.setTitle(NSLocalizedString("_continue_", comment: ""), for: .normal)
         buttonContinue.isEnabled = false
-        buttonContinue.setTitleColor(.lightGray, for: .normal)
-        buttonContinue.layer.backgroundColor = NCBrandColor.shared.graySoft.withAlphaComponent(0.5).cgColor
+        
+        changeTheming()
+    }
+    
+    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
+        super.traitCollectionDidChange(previousTraitCollection)
+        
+        changeTheming()
+    }
+    
+    // MARK: - Theming
+    
+    func changeTheming(){
+        
+        view.backgroundColor = NCBrandColor.shared.systemGroupedBackground
+        tableView.backgroundColor = NCBrandColor.shared.systemGroupedBackground
+        viewSwitch.backgroundColor = NCBrandColor.shared.systemGroupedBackground
+        viewButton.backgroundColor = NCBrandColor.shared.systemGroupedBackground
     }
     
     // MARK: - Action
@@ -148,7 +165,7 @@ extension NCCreateFormUploadConflictDelegate {
             }
             
             switchAlreadyExistingFiles.isOn = true
-            NCContentPresenter.shared.messageNotification("_info_", description: "_file_not_rewite_doc_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.ErrorInternalError, forced: true)
+            NCContentPresenter.shared.messageNotification("_info_", description: "_file_not_rewite_doc_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode: NCGlobal.shared.errorInternalError, forced: true)
         }
         
         tableView.reloadData()
@@ -263,6 +280,8 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
         
         if let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as? NCCreateFormUploadConflictCell {
             
+            cell.backgroundColor = tableView.backgroundColor
+            
             let metadataNewFile = metadatasUploadInConflict[indexPath.row]
 
             cell.ocId = metadataNewFile.ocId
@@ -338,36 +357,29 @@ extension NCCreateFormUploadConflict: UITableViewDataSource {
                 } else {
                     
                     CCUtility.extractImageVideoFromAssetLocalIdentifier(forUpload: metadataNewFile, notification: false) { (metadataNew, fileNamePath) in
-                        DispatchQueue.global(qos: .background).async {
-                            if metadataNew != nil {
-                                self.fileNamesPath[metadataNewFile.fileNameView] = fileNamePath!
+                       
+                        if metadataNew != nil {
+                            self.fileNamesPath[metadataNewFile.fileNameView] = fileNamePath!
+                            
+                            do {
                                 
-                                do {
-                                    
-                                    let fileDictionary = try FileManager.default.attributesOfItem(atPath: fileNamePath!)
-                                    let fileSize = fileDictionary[FileAttributeKey.size] as! Int64
-                                    
-                                    if mediaType == PHAssetMediaType.image {
-                                        let data = try Data(contentsOf: URL(fileURLWithPath: fileNamePath!))
-                                        if let image = UIImage(data: data) {
-                                            DispatchQueue.main.async {
-                                                cell.imageNewFile.image = image
-                                            }
-                                        }
-                                    } else if mediaType == PHAssetMediaType.video {
-                                        if let image = NCUtility.shared.imageFromVideo(url: URL(fileURLWithPath: fileNamePath!), at: 0) {
-                                            DispatchQueue.main.async {
-                                                cell.imageNewFile.image = image
-                                            }
-                                        }
+                                let fileDictionary = try FileManager.default.attributesOfItem(atPath: fileNamePath!)
+                                let fileSize = fileDictionary[FileAttributeKey.size] as! Int64
+                                
+                                if mediaType == PHAssetMediaType.image {
+                                    let data = try Data(contentsOf: URL(fileURLWithPath: fileNamePath!))
+                                    if let image = UIImage(data: data) {
+                                        cell.imageNewFile.image = image
                                     }
-                                    
-                                    DispatchQueue.main.async {
-                                        cell.labelDetailNewFile.text = CCUtility.dateDiff(date) + "\n" + CCUtility.transformedSize(fileSize)
+                                } else if mediaType == PHAssetMediaType.video {
+                                    if let image = NCUtility.shared.imageFromVideo(url: URL(fileURLWithPath: fileNamePath!), at: 0) {
+                                        cell.imageNewFile.image = image
                                     }
-                                    
-                                } catch { print("Error: \(error)") }
-                            }
+                                }
+                                
+                                cell.labelDetailNewFile.text = CCUtility.dateDiff(date) + "\n" + CCUtility.transformedSize(fileSize)
+                               
+                            } catch { print("Error: \(error)") }
                         }
                     }
                 }

+ 1 - 1
iOSClient/Main/Create cloud/NCCreateFormUploadConflictCell.swift

@@ -21,7 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 
 class NCCreateFormUploadConflictCell: UITableViewCell {
     

+ 43 - 40
iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

@@ -21,13 +21,19 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 import NCCommunication
 
 // MARK: -
 
 @objc class NCCreateFormUploadDocuments: XLFormViewController, NCSelectDelegate, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, NCCreateFormUploadConflictDelegate {
+
+    @IBOutlet weak var indicator: UIActivityIndicatorView!
+    @IBOutlet weak var collectionView: UICollectionView!
+    @IBOutlet weak var collectionViewHeigth: NSLayoutConstraint!
     
+    let appDelegate = UIApplication.shared.delegate as! AppDelegate
+
     var editorId = ""
     var creatorId = ""
     var typeTemplate = ""
@@ -40,22 +46,16 @@ import NCCommunication
     var listOfTemplate: [NCCommunicationEditorTemplates] = []
     var selectTemplate: NCCommunicationEditorTemplates?
     
-    @IBOutlet weak var indicator: UIActivityIndicatorView!
-    @IBOutlet weak var collectionView: UICollectionView!
-    @IBOutlet weak var collectionViewHeigth: NSLayoutConstraint!
-    
     // Layout
     let numItems = 2
     let sectionInsets: CGFloat = 10
     let highLabelName: CGFloat = 20
     
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-
     // MARK: - View Life Cycle
     
     override func viewDidLoad() {
         super.viewDidLoad()
-        
+                
         if serverUrl == NCUtilityFileSystem.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account) {
             fileNameFolder = "/"
         } else {
@@ -63,7 +63,7 @@ import NCCommunication
         }
         
         self.tableView.separatorStyle = UITableViewCell.SeparatorStyle.none
-                
+
         let cancelButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(cancel))
         let saveButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_save_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(save))
         
@@ -74,21 +74,30 @@ import NCCommunication
         // title 
         self.title = titleForm
       
-        NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
-
         changeTheming()
         
+        initializeForm()
+        
         // load the templates available
         getTemplate()
     }
     
-    @objc func changeTheming() {
-        view.backgroundColor = NCBrandColor.shared.backgroundForm
-        collectionView.backgroundColor = NCBrandColor.shared.backgroundForm
-        tableView.backgroundColor = NCBrandColor.shared.backgroundForm
-        collectionView.reloadData()
+    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
+        super.traitCollectionDidChange(previousTraitCollection)
+        
+        changeTheming()
+    }
+    
+    // MARK: - Theming
+    
+    func changeTheming() {
+        
+        view.backgroundColor = NCBrandColor.shared.systemGroupedBackground
+        collectionView.backgroundColor = NCBrandColor.shared.systemGroupedBackground
+        tableView.backgroundColor = NCBrandColor.shared.secondarySystemGroupedBackground
+        
         tableView.reloadData()
-        initializeForm()
+        collectionView.reloadData()
     }
     
     // MARK: - Tableview (XLForm)
@@ -109,13 +118,13 @@ import NCCommunication
         row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: fileNameFolder)
         row.action.formSelector = #selector(changeDestinationFolder(_:))
         row.value = fileNameFolder
-        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
+        row.cellConfig["backgroundColor"] = tableView.backgroundColor
 
         row.cellConfig["imageView.image"] =  UIImage(named: "folder")!.image(color: NCBrandColor.shared.brandElement, size: 25)
         
         row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.label
 
         section.addFormRow(row)
         
@@ -124,17 +133,17 @@ import NCCommunication
         section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_filename_", comment: "").uppercased())
         form.addFormSection(section)
         
-        row = XLFormRowDescriptor(tag: "fileName", rowType: XLFormRowDescriptorTypeAccount, title: NSLocalizedString("_filename_", comment: ""))
+        row = XLFormRowDescriptor(tag: "fileName", rowType: XLFormRowDescriptorTypeText, title: NSLocalizedString("_filename_", comment: ""))
         row.value = fileName
-        row.cellConfig["backgroundColor"] = NCBrandColor.shared.backgroundForm
+        row.cellConfig["backgroundColor"] = tableView.backgroundColor
         
         row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
         row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textField.textColor"] = NCBrandColor.shared.textView
+        row.cellConfig["textField.textColor"] = NCBrandColor.shared.label
         
         row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
         row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
-        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.textView
+        row.cellConfig["textLabel.textColor"] = NCBrandColor.shared.label
         
         section.addFormRow(row)
         
@@ -145,7 +154,7 @@ import NCCommunication
         let header: UITableViewHeaderFooterView = view as! UITableViewHeaderFooterView
         header.textLabel?.font = UIFont.systemFont(ofSize: 13.0)
         header.textLabel?.textColor = .gray
-        header.tintColor = NCBrandColor.shared.backgroundForm
+        header.tintColor = tableView.backgroundColor
     }
 
     // MARK: - CollectionView
@@ -187,16 +196,16 @@ import NCCommunication
         // name
         let name = cell.viewWithTag(200) as! UILabel
         name.text = template.name
-        name.textColor = NCBrandColor.shared.backgroundView
+        name.textColor = NCBrandColor.shared.secondarySystemGroupedBackground
         
         // select
         let imageSelect = cell.viewWithTag(300) as! UIImageView
         if selectTemplate != nil && selectTemplate?.name == template.name {
-            cell.backgroundColor = NCBrandColor.shared.textView
+            cell.backgroundColor = NCBrandColor.shared.label
             imageSelect.image = UIImage(named: "plus100")
             imageSelect.isHidden = false
         } else {
-            cell.backgroundColor = NCBrandColor.shared.backgroundView
+            cell.backgroundColor = NCBrandColor.shared.secondarySystemGroupedBackground
             imageSelect.isHidden = true
         }
         
@@ -215,7 +224,7 @@ import NCCommunication
     
     // MARK: - Action
     
-    func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], buttonType: String, overwrite: Bool) {
+    func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], overwrite: Bool, copy: Bool, move: Bool) {
         
         guard let serverUrl = serverUrl else {
             return
@@ -243,14 +252,8 @@ import NCCommunication
         let viewController = navigationController.topViewController as! NCSelect
         
         viewController.delegate = self
-        viewController.hideButtonCreateFolder = false
-        viewController.includeDirectoryE2EEncryption = false
-        viewController.includeImages = false
-        viewController.selectFile = false
-        viewController.titleButtonDone = NSLocalizedString("_select_", comment: "")
-        viewController.type = ""
+        viewController.typeOfCommandView = .selectCreateFolder
 
-        navigationController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
         self.present(navigationController, animated: true, completion: nil)
     }
     
@@ -277,7 +280,7 @@ import NCCommunication
             
             if NCManageDatabase.shared.getMetadataConflict(account: appDelegate.account, serverUrl: serverUrl, fileName: String(describing: fileNameForm)) != nil {
                 
-                let metadataForUpload = NCManageDatabase.shared.createMetadata(account: appDelegate.account, fileName: String(describing: fileNameForm), fileNameView: String(describing: fileNameForm), ocId: "", serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "", livePhoto: false, chunk: false)
+                let metadataForUpload = NCManageDatabase.shared.createMetadata(account: appDelegate.account, fileName: String(describing: fileNameForm), fileNameView: String(describing: fileNameForm), ocId: "", serverUrl: serverUrl, urlBase: appDelegate.urlBase, url: "", contentType: "", livePhoto: false)
                 
                 guard let conflictViewController = UIStoryboard(name: "NCCreateFormUploadConflict", bundle: nil).instantiateInitialViewController() as? NCCreateFormUploadConflict else { return }
                 conflictViewController.textLabelDetailNewFile = NSLocalizedString("_now_", comment: "")
@@ -331,10 +334,10 @@ import NCCommunication
                         let results = NCCommunicationCommon.shared.getInternalType(fileName: fileName, mimeType: "", directory: false)
                         
                         self.dismiss(animated: true, completion: {
-                            let metadata = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, fileName: fileName, fileNameView: fileName, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url ?? "", contentType: results.mimeType, livePhoto: false, chunk: false)
+                            let metadata = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, fileName: fileName, fileNameView: fileName, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url ?? "", contentType: results.mimeType, livePhoto: false)
                             
                             if let viewController = self.appDelegate.activeViewController {
-                                NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata])
+                                NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: nil)
                             }
                         })
                     }
@@ -356,10 +359,10 @@ import NCCommunication
                     self.dismiss(animated: true, completion: {
                     
                         let createFileName = (fileName as NSString).deletingPathExtension + "." + self.fileNameExtension
-                        let metadata = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, fileName: createFileName, fileNameView: createFileName, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url!, contentType: "", livePhoto: false, chunk: false)
+                        let metadata = NCManageDatabase.shared.createMetadata(account: self.appDelegate.account, fileName: createFileName, fileNameView: createFileName, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url!, contentType: "", livePhoto: false)
                     
                         if let viewController = self.appDelegate.activeViewController {
-                            NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata])
+                            NCViewer.shared.view(viewController: viewController, metadata: metadata, metadatas: [metadata], imageIcon: nil)
                         }
                    })
                    

Some files were not shown because too many files changed in this diff