فهرست منبع

Merge pull request #2511 from nextcloud/develop

Version 4.8.4
Marino Faggiana 1 سال پیش
والد
کامیت
577bdcb3b6
95فایلهای تغییر یافته به همراه2101 افزوده شده و 540 حذف شده
  1. 68 0
      .github/workflows/additional-targets.yml
  2. 2 2
      .github/workflows/lint.yml
  3. 35 32
      .github/workflows/xcode.yml
  4. 2 0
      .gitignore
  5. 3 0
      .slather.yml
  6. 1 0
      .swiftlint.yml
  7. 3 0
      Gemfile
  8. 636 42
      Nextcloud.xcodeproj/project.pbxproj
  9. 46 2
      Nextcloud.xcodeproj/xcshareddata/xcschemes/File Provider Extension.xcscheme
  10. 46 3
      Nextcloud.xcodeproj/xcshareddata/xcschemes/Nextcloud.xcscheme
  11. 44 0
      Nextcloud.xcodeproj/xcshareddata/xcschemes/Notification Service Extension.xcscheme
  12. 46 2
      Nextcloud.xcodeproj/xcshareddata/xcschemes/Share.xcscheme
  13. 44 0
      Nextcloud.xcodeproj/xcshareddata/xcschemes/Widget.xcscheme
  14. 50 0
      README.md
  15. 13 7
      Share/NCShareExtension+Files.swift
  16. 3 0
      Share/NCShareExtension+NCDelegate.swift
  17. 1 1
      Share/NCShareExtension.swift
  18. 18 0
      Sourcery/EnvVars.stencil
  19. BIN
      Sourcery/bin/sourcery
  20. 81 0
      Tests/NextcloudIntegrationTests/FilesIntegrationTests.swift
  21. 83 0
      Tests/NextcloudIntegrationTests/LoginIntegrationTests.swift
  22. 18 0
      Tests/NextcloudSnapshotTests/Extensions/SwiftUIView+Extensions.swift
  23. 24 0
      Tests/NextcloudSnapshotTests/NextcloudSnapshotTests.swift
  24. BIN
      Tests/NextcloudSnapshotTests/__Snapshots__/NextcloudSnapshotTests/test_CapalitiesView.DefaultPreviewConfiguration.heic
  25. BIN
      Tests/NextcloudSnapshotTests/__Snapshots__/NextcloudSnapshotTests/test_HUDView.DefaultPreviewConfiguration.heic
  26. 35 0
      Tests/NextcloudUITests/BaseUIXCTestCase.swift
  27. 64 0
      Tests/NextcloudUITests/LoginUITests.swift
  28. 1 1
      Tests/NextcloudUnitTests/NextcloudUnitTests.swift
  29. 49 0
      create-docker-test-server.sh
  30. 36 0
      iOSClient/AppDelegate.swift
  31. 72 59
      iOSClient/Diagnostics/NCCapabilitiesView.swift
  32. 21 23
      iOSClient/EmptyView/NCEmptyDataSet.swift
  33. 21 17
      iOSClient/EmptyView/NCEmptyView.xib
  34. 0 0
      iOSClient/Extensions/Optional+Extension.swift
  35. 1 1
      iOSClient/Extensions/PHAsset+Extension.swift
  36. 6 2
      iOSClient/Extensions/UIImage+Extension.swift
  37. 6 1
      iOSClient/Extensions/View+Extension.swift
  38. 0 1
      iOSClient/Favorites/NCFavorite.swift
  39. 0 1
      iOSClient/Files/NCFiles.swift
  40. 12 1
      iOSClient/GUI/HUDView.swift
  41. 0 1
      iOSClient/Groupfolders/NCGroupfolders.swift
  42. 15 0
      iOSClient/Images.xcassets/more-apps-template.imageset/Contents.json
  43. 0 0
      iOSClient/Images.xcassets/more-apps-template.imageset/more-apps.svg
  44. 15 0
      iOSClient/Images.xcassets/notes-template.imageset/Contents.json
  45. 1 0
      iOSClient/Images.xcassets/notes-template.imageset/notes.svg
  46. 0 26
      iOSClient/Images.xcassets/switchGrid.imageset/Contents.json
  47. BIN
      iOSClient/Images.xcassets/switchGrid.imageset/switchGrid.png
  48. BIN
      iOSClient/Images.xcassets/switchGrid.imageset/switchGrid@2x.png
  49. BIN
      iOSClient/Images.xcassets/switchGrid.imageset/switchGrid@3x.png
  50. 0 26
      iOSClient/Images.xcassets/switchList.imageset/Contents.json
  51. BIN
      iOSClient/Images.xcassets/switchList.imageset/switchList.png
  52. BIN
      iOSClient/Images.xcassets/switchList.imageset/switchList@2x.png
  53. BIN
      iOSClient/Images.xcassets/switchList.imageset/switchList@3x.png
  54. 15 0
      iOSClient/Images.xcassets/talk-template.imageset/Contents.json
  55. BIN
      iOSClient/Images.xcassets/talk-template.imageset/talk.png
  56. 11 15
      iOSClient/Main/Collection Common/NCCollectionViewCommon.swift
  57. 12 84
      iOSClient/Main/Section Header Footer/NCSectionHeaderMenu.swift
  58. 28 86
      iOSClient/Main/Section Header Footer/NCSectionHeaderMenu.xib
  59. 20 12
      iOSClient/NCGlobal.swift
  60. 277 36
      iOSClient/Networking/E2EE/NCEndToEndEncryption.m
  61. 0 7
      iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift
  62. 9 10
      iOSClient/Networking/NCNetworking.swift
  63. 3 0
      iOSClient/Notification/NCNotification.storyboard
  64. 4 2
      iOSClient/Notification/NCNotification.swift
  65. 0 1
      iOSClient/Offline/NCOffline.swift
  66. 0 1
      iOSClient/Recent/NCRecent.swift
  67. 1 2
      iOSClient/Select/NCSelect.swift
  68. 0 1
      iOSClient/Shares/NCShares.swift
  69. BIN
      iOSClient/Supporting Files/ar.lproj/InfoPlist.strings
  70. BIN
      iOSClient/Supporting Files/ar.lproj/Localizable.strings
  71. BIN
      iOSClient/Supporting Files/cs-CZ.lproj/Localizable.strings
  72. BIN
      iOSClient/Supporting Files/de.lproj/Localizable.strings
  73. BIN
      iOSClient/Supporting Files/el.lproj/Localizable.strings
  74. BIN
      iOSClient/Supporting Files/es.lproj/Localizable.strings
  75. BIN
      iOSClient/Supporting Files/fr.lproj/Localizable.strings
  76. BIN
      iOSClient/Supporting Files/gl.lproj/InfoPlist.strings
  77. BIN
      iOSClient/Supporting Files/gl.lproj/Localizable.strings
  78. BIN
      iOSClient/Supporting Files/hu.lproj/Localizable.strings
  79. BIN
      iOSClient/Supporting Files/ko.lproj/Localizable.strings
  80. BIN
      iOSClient/Supporting Files/pt-BR.lproj/Localizable.strings
  81. BIN
      iOSClient/Supporting Files/ru.lproj/Localizable.strings
  82. BIN
      iOSClient/Supporting Files/sl.lproj/Localizable.strings
  83. BIN
      iOSClient/Supporting Files/sr.lproj/Localizable.strings
  84. BIN
      iOSClient/Supporting Files/sv.lproj/Localizable.strings
  85. BIN
      iOSClient/Supporting Files/tr.lproj/Localizable.strings
  86. BIN
      iOSClient/Supporting Files/uk.lproj/Localizable.strings
  87. BIN
      iOSClient/Supporting Files/zh-Hans.lproj/Localizable.strings
  88. BIN
      iOSClient/Supporting Files/zh_HK.lproj/Localizable.strings
  89. 0 1
      iOSClient/Transfers/NCTransfers.swift
  90. 2 11
      iOSClient/Trash/NCTrash+CollectionView.swift
  91. 2 2
      iOSClient/Trash/NCTrash.swift
  92. 1 0
      iOSClient/Viewer/NCViewer.swift
  93. 58 3
      iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift
  94. 1 1
      iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift
  95. 35 14
      iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

+ 68 - 0
.github/workflows/additional-targets.yml

@@ -0,0 +1,68 @@
+name: Build additional targets
+
+on:
+  push:
+    branches:
+      - master
+      - develop
+  pull_request:
+    types: [synchronize, opened, reopened, ready_for_review]
+    branches:
+      - master
+      - develop
+
+jobs:
+  build-and-test:
+    name: Build and Test
+    runs-on: macOS-latest
+    if: github.event.pull_request.draft == false
+    env:
+      PROJECT: Nextcloud.xcodeproj
+      DESTINATION: platform=iOS Simulator,name=iPhone 14
+    steps:
+    - name: Set env var
+      run: echo "DEVELOPER_DIR=$(xcode-select --print-path)" >> $GITHUB_ENV
+    - uses: actions/checkout@v3
+    - name: Setup Bundler and Install Gems
+      run: |
+        gem install bundler
+        bundle install
+        bundle update
+    - name: Restore Carhage Cache
+      uses: actions/cache@v3
+      id: carthage-cache
+      with:
+        path: Carthage
+        key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }}
+        restore-keys: |
+          ${{ runner.os }}-carthage-
+    - name: Carthage
+      if: steps.carthage-cache.outputs.cache-hit != 'true'
+      run: carthage bootstrap --use-xcframeworks --platform iOS
+    - name: Download GoogleService-Info.plist
+      run: wget "https://raw.githubusercontent.com/firebase/quickstart-ios/master/mock-GoogleService-Info.plist" -O GoogleService-Info.plist
+    - name: Build iOS Share
+      run: |
+        xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
+      env:
+          SCHEME: Share
+    - name: Build iOS File Extension
+      run: |
+        xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
+      env:
+          SCHEME: File Provider Extension
+    - name: Build iOS Notification Extension
+      run: |
+        xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
+      env:
+          SCHEME: Notification Service Extension
+    - name: Build iOS Widget
+      run: |
+        xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
+      env:
+          SCHEME: Widget
+    - name: Build iOS Widget Dashboard IntentHandler
+      run: |
+        xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
+      env:
+          SCHEME: WidgetDashboardIntentHandler

+ 2 - 2
.github/workflows/lint.yml

@@ -20,7 +20,7 @@ jobs:
     if: github.event.pull_request.draft == false
     if: github.event.pull_request.draft == false
 
 
     steps:
     steps:
-     - uses: actions/checkout@v2
+     - uses: actions/checkout@v3
 
 
      - name: GitHub Action for SwiftLint
      - name: GitHub Action for SwiftLint
-       uses: norio-nomura/action-swiftlint@3.1.0
+       uses: norio-nomura/action-swiftlint@3.2.1

+ 35 - 32
.github/workflows/xcode.yml

@@ -1,4 +1,4 @@
-name: Build
+name: Build main target
 
 
 on:
 on:
   push:
   push:
@@ -7,23 +7,30 @@ on:
       - develop
       - develop
   pull_request:
   pull_request:
     types: [synchronize, opened, reopened, ready_for_review]
     types: [synchronize, opened, reopened, ready_for_review]
-    branches: 
+    branches:
       - master
       - master
       - develop
       - develop
 
 
 jobs:
 jobs:
-  XCBuild:
+  build-and-test:
+    name: Build and Test
     runs-on: macOS-latest
     runs-on: macOS-latest
     if: github.event.pull_request.draft == false
     if: github.event.pull_request.draft == false
     env:
     env:
       PROJECT: Nextcloud.xcodeproj
       PROJECT: Nextcloud.xcodeproj
       DESTINATION: platform=iOS Simulator,name=iPhone 14
       DESTINATION: platform=iOS Simulator,name=iPhone 14
+      SCHEME: Nextcloud
     steps:
     steps:
     - name: Set env var
     - name: Set env var
       run: echo "DEVELOPER_DIR=$(xcode-select --print-path)" >> $GITHUB_ENV
       run: echo "DEVELOPER_DIR=$(xcode-select --print-path)" >> $GITHUB_ENV
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v3
+    - name: Setup Bundler and Install Gems
+      run: |
+        gem install bundler
+        bundle install
+        bundle update
     - name: Restore Carhage Cache
     - name: Restore Carhage Cache
-      uses: actions/cache@v2
+      uses: actions/cache@v3
       id: carthage-cache
       id: carthage-cache
       with:
       with:
         path: Carthage
         path: Carthage
@@ -35,34 +42,30 @@ jobs:
       run: carthage bootstrap --use-xcframeworks --platform iOS
       run: carthage bootstrap --use-xcframeworks --platform iOS
     - name: Download GoogleService-Info.plist
     - name: Download GoogleService-Info.plist
       run: wget "https://raw.githubusercontent.com/firebase/quickstart-ios/master/mock-GoogleService-Info.plist" -O GoogleService-Info.plist
       run: wget "https://raw.githubusercontent.com/firebase/quickstart-ios/master/mock-GoogleService-Info.plist" -O GoogleService-Info.plist
-    - name: Build & Test Nextcloud iOS
-      run: |
-        xcodebuild clean build test -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
-      env:
-          SCHEME: Nextcloud
-    - name: Build iOS Share
+    - name: Install docker
       run: |
       run: |
-        xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
-      env:
-          SCHEME: Share
-    - name: Build iOS File Extension
+        brew install docker
+        colima start
+    - name: Create docker test server and export enviroment variables
       run: |
       run: |
-        xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
-      env:
-          SCHEME: File Provider Extension
-    - name: Build iOS Notification Extension
-      run: |
-        xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
-      env:
-          SCHEME: Notification Service Extension
-    - name: Build iOS Widget
+        source ./create-docker-test-server.sh
+        if [ ! -f ".env-vars" ]; then
+            touch .env-vars
+            echo "export TEST_SERVER_URL=$TEST_SERVER_URL" >> .env-vars
+            echo "export TEST_USER=$TEST_USER" >> .env-vars
+            echo "export TEST_APP_PASSWORD=$TEST_APP_PASSWORD" >> .env-vars
+        fi
+    - name: Build & Test Nextcloud iOS
       run: |
       run: |
-        xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
-      env:
-          SCHEME: Widget
-    - name: Build iOS Widget Dashboard IntentHandler
+        set -o pipefail && xcodebuild test -project $PROJECT \
+        -scheme "$SCHEME" \
+        -destination "$DESTINATION" \
+        -enableCodeCoverage YES \
+        -test-iterations 3 \
+        -retry-tests-on-failure \
+        | xcpretty
+    - name: Upload coverage to codecov
       run: |
       run: |
-        xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
-      env:
-          SCHEME: WidgetDashboardIntentHandler
-          
+        bundle exec slather
+        bash <(curl -s https://codecov.io/bash) -f ./cobertura.xml -X coveragepy -X gcov -X xcode -t ${{ secrets.CODECOV_TOKEN }}
+

+ 2 - 0
.gitignore

@@ -42,3 +42,5 @@ Carthage/
 .swiftpm
 .swiftpm
 Package.resolved
 Package.resolved
 
 
+*.generated.swift
+/.env-vars

+ 3 - 0
.slather.yml

@@ -0,0 +1,3 @@
+coverage_service: cobertura_xml
+xcodeproj: Nextcloud.xcodeproj
+scheme: Nextcloud

+ 1 - 0
.swiftlint.yml

@@ -42,6 +42,7 @@ disabled_rules:
 excluded:
 excluded:
   - Carthage
   - Carthage
   - Pods
   - Pods
+  - Tests
 
 
   # iOS Files Quarantine
   # iOS Files Quarantine
 
 

+ 3 - 0
Gemfile

@@ -0,0 +1,3 @@
+source 'https://rubygems.org'
+gem 'slather'
+gem 'xcpretty' 

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 636 - 42
Nextcloud.xcodeproj/project.pbxproj


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

@@ -57,8 +57,52 @@
             <BuildableReference
             <BuildableReference
                BuildableIdentifier = "primary"
                BuildableIdentifier = "primary"
                BlueprintIdentifier = "AF8ED1F82757821000B8DBC4"
                BlueprintIdentifier = "AF8ED1F82757821000B8DBC4"
-               BuildableName = "NextcloudTests.xctest"
-               BlueprintName = "NextcloudTests"
+               BuildableName = "NextcloudUnitTests.xctest"
+               BlueprintName = "NextcloudUnitTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C0046CD92A17B98400D87C9D"
+               BuildableName = "NextcloudUITests.xctest"
+               BlueprintName = "NextcloudUITests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C04E2F1F2A17BB4D001BAD85"
+               BuildableName = "NextcloudIntegrationTests.xctest"
+               BlueprintName = "NextcloudIntegrationTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C04E2F2C2A17BB77001BAD85"
+               BuildableName = "NextcloudEndToEndTests.xctest"
+               BlueprintName = "NextcloudEndToEndTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "F31F69412A2F6D4500162F76"
+               BuildableName = "NextcloudSnapshotTests.xctest"
+               BlueprintName = "NextcloudSnapshotTests"
                ReferencedContainer = "container:Nextcloud.xcodeproj">
                ReferencedContainer = "container:Nextcloud.xcodeproj">
             </BuildableReference>
             </BuildableReference>
          </TestableReference>
          </TestableReference>

+ 46 - 3
Nextcloud.xcodeproj/xcshareddata/xcschemes/Nextcloud.xcscheme

@@ -26,7 +26,8 @@
       buildConfiguration = "Debug"
       buildConfiguration = "Debug"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
-      shouldUseLaunchSchemeArgsEnv = "YES"
+      shouldUseLaunchSchemeArgsEnv = "NO"
+      enableThreadSanitizer = "YES"
       codeCoverageEnabled = "YES">
       codeCoverageEnabled = "YES">
       <MacroExpansion>
       <MacroExpansion>
          <BuildableReference
          <BuildableReference
@@ -43,8 +44,49 @@
             <BuildableReference
             <BuildableReference
                BuildableIdentifier = "primary"
                BuildableIdentifier = "primary"
                BlueprintIdentifier = "AF8ED1F82757821000B8DBC4"
                BlueprintIdentifier = "AF8ED1F82757821000B8DBC4"
-               BuildableName = "NextcloudTests.xctest"
-               BlueprintName = "NextcloudTests"
+               BuildableName = "NextcloudUnitTests.xctest"
+               BlueprintName = "NextcloudUnitTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C0046CD92A17B98400D87C9D"
+               BuildableName = "NextcloudUITests.xctest"
+               BlueprintName = "NextcloudUITests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C04E2F1F2A17BB4D001BAD85"
+               BuildableName = "NextcloudIntegrationTests.xctest"
+               BlueprintName = "NextcloudIntegrationTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C04E2F2C2A17BB77001BAD85"
+               BuildableName = "NextcloudEndToEndTests.xctest"
+               BlueprintName = "NextcloudEndToEndTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "F31F69412A2F6D4500162F76"
+               BuildableName = "NextcloudSnapshotTests.xctest"
+               BlueprintName = "NextcloudSnapshotTests"
                ReferencedContainer = "container:Nextcloud.xcodeproj">
                ReferencedContainer = "container:Nextcloud.xcodeproj">
             </BuildableReference>
             </BuildableReference>
          </TestableReference>
          </TestableReference>
@@ -54,6 +96,7 @@
       buildConfiguration = "Debug"
       buildConfiguration = "Debug"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      enableThreadSanitizer = "YES"
       launchStyle = "0"
       launchStyle = "0"
       useCustomWorkingDirectory = "NO"
       useCustomWorkingDirectory = "NO"
       ignoresPersistentStateOnLaunch = "NO"
       ignoresPersistentStateOnLaunch = "NO"

+ 44 - 0
Nextcloud.xcodeproj/xcshareddata/xcschemes/Notification Service Extension.xcscheme

@@ -43,6 +43,50 @@
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       shouldUseLaunchSchemeArgsEnv = "YES">
       shouldUseLaunchSchemeArgsEnv = "YES">
       <Testables>
       <Testables>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C0046CD92A17B98400D87C9D"
+               BuildableName = "NextcloudUITests.xctest"
+               BlueprintName = "NextcloudUITests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C04E2F1F2A17BB4D001BAD85"
+               BuildableName = "NextcloudIntegrationTests.xctest"
+               BlueprintName = "NextcloudIntegrationTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C04E2F2C2A17BB77001BAD85"
+               BuildableName = "NextcloudEndToEndTests.xctest"
+               BlueprintName = "NextcloudEndToEndTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "F31F69412A2F6D4500162F76"
+               BuildableName = "NextcloudSnapshotTests.xctest"
+               BlueprintName = "NextcloudSnapshotTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
       </Testables>
       </Testables>
    </TestAction>
    </TestAction>
    <LaunchAction
    <LaunchAction

+ 46 - 2
Nextcloud.xcodeproj/xcshareddata/xcschemes/Share.xcscheme

@@ -57,8 +57,52 @@
             <BuildableReference
             <BuildableReference
                BuildableIdentifier = "primary"
                BuildableIdentifier = "primary"
                BlueprintIdentifier = "AF8ED1F82757821000B8DBC4"
                BlueprintIdentifier = "AF8ED1F82757821000B8DBC4"
-               BuildableName = "NextcloudTests.xctest"
-               BlueprintName = "NextcloudTests"
+               BuildableName = "NextcloudUnitTests.xctest"
+               BlueprintName = "NextcloudUnitTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C0046CD92A17B98400D87C9D"
+               BuildableName = "NextcloudUITests.xctest"
+               BlueprintName = "NextcloudUITests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C04E2F1F2A17BB4D001BAD85"
+               BuildableName = "NextcloudIntegrationTests.xctest"
+               BlueprintName = "NextcloudIntegrationTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C04E2F2C2A17BB77001BAD85"
+               BuildableName = "NextcloudEndToEndTests.xctest"
+               BlueprintName = "NextcloudEndToEndTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "F31F69412A2F6D4500162F76"
+               BuildableName = "NextcloudSnapshotTests.xctest"
+               BlueprintName = "NextcloudSnapshotTests"
                ReferencedContainer = "container:Nextcloud.xcodeproj">
                ReferencedContainer = "container:Nextcloud.xcodeproj">
             </BuildableReference>
             </BuildableReference>
          </TestableReference>
          </TestableReference>

+ 44 - 0
Nextcloud.xcodeproj/xcshareddata/xcschemes/Widget.xcscheme

@@ -43,6 +43,50 @@
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       shouldUseLaunchSchemeArgsEnv = "YES">
       shouldUseLaunchSchemeArgsEnv = "YES">
       <Testables>
       <Testables>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C0046CD92A17B98400D87C9D"
+               BuildableName = "NextcloudUITests.xctest"
+               BlueprintName = "NextcloudUITests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C04E2F1F2A17BB4D001BAD85"
+               BuildableName = "NextcloudIntegrationTests.xctest"
+               BlueprintName = "NextcloudIntegrationTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "C04E2F2C2A17BB77001BAD85"
+               BuildableName = "NextcloudEndToEndTests.xctest"
+               BlueprintName = "NextcloudEndToEndTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
+         <TestableReference
+            skipped = "NO"
+            parallelizable = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "F31F69412A2F6D4500162F76"
+               BuildableName = "NextcloudSnapshotTests.xctest"
+               BlueprintName = "NextcloudSnapshotTests"
+               ReferencedContainer = "container:Nextcloud.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
       </Testables>
       </Testables>
    </TestAction>
    </TestAction>
    <LaunchAction
    <LaunchAction

+ 50 - 0
README.md

@@ -79,3 +79,53 @@ If you need assistance or want to ask a question about the iOS app, you are welc
 Do you want to try the latest version in development of Nextcloud iOS ? Simple, follow this simple step
 Do you want to try the latest version in development of Nextcloud iOS ? Simple, follow this simple step
 
 
 [Apple TestFlight](https://testflight.apple.com/join/RXEJbWj9)
 [Apple TestFlight](https://testflight.apple.com/join/RXEJbWj9)
+
+## Testing
+
+#### Note: If a Unit or Integration test exclusively uses and tests NextcloudKit functions and components, then write that test in the NextcloudKit repo. NextcloudKit is used in many other repos as an API, and it's better if such tests are located there.
+
+### Unit tests:
+
+There are currently no preresquites for unit testing that need to be done. Mock everything that's not needed. 
+
+### Integration tests:
+To run integration tests, we need a docker instance of a Nextcloud test server.
+The CI does all this automatically, but to do it manually:
+1. Run `docker run --rm -d -p 8080:80 ghcr.io/juliushaertl/nextcloud-dev-php80:latest` to spin up a docker container of the Nextcloud test server.
+2. Log in on the test server and generate an app password for device. There are a couple test accounts, but `admin` as username and password works best.
+3. Build the iOS project once. This will generate an `.env-vars` file in the root directory. It contains env vars that the project will use for testing.
+4. Provide proper values for the env vars inside the file. Here is an example:
+```
+export TEST_SERVER_URL=http://localhost:8080
+export TEST_USER=nextcloud
+export TEST_PASSWORD=FAeSR-6Jk7s-DzLny-CCQHL-f49BP
+```
+5. Build the iOS project again. If all the values are set correctly you will see a generated file called `EnvVars.generated.swift`. It contains the env vars as Swift fields that can be easily used in code:
+```
+/**
+This is generated from the .env-vars file in the root directory. If there is an environment variable here that is needed and not filled, please look into this file.
+ */
+ public struct EnvVars {
+  static let testUser = "nextcloud"
+  static let testPassword = "FAeSR-6Jk7s-DzLny-CCQHL-f49BP"
+  static let testServerUrl = "http://localhost:8080"
+}
+```
+6. You can now run the integration tests. They will use the env vars to connect to the test server to do the testing. 
+
+
+### UI tests
+
+UI tests also use the docker server, but besides that there is nothing else you need to do.
+
+### Snapshot tests
+
+Snapshot tests are made via this library: https://github.com/pointfreeco/swift-snapshot-testing and these 2 extensions:
+1. https://github.com/doordash-oss/swiftui-preview-snapshots - for creating SwiftUI snapshot tests via previews.
+2. https://github.com/alexey1312/SnapshotTestingHEIC - makes snapshot images HEIC instead of PNGs for much reduced size.
+
+Snapshot tests are a great way to test if UI elements are consistent with designs and don't break with new commits, but they can be very finicky and the smallest change can cause them to fail. Keep in mind:
+
+- For SwiftUI snapshot tests, It's always a good idea to utilize previews, as they do not depend on device/app state and it has less chances to fail due to wrong state.
+
+- For UIKit snapshot tests, try to include mock dependencies to always make sure the UI is rendered the same way. Even a text change can cause the tests to fail.

+ 13 - 7
Share/NCShareExtension+Files.swift

@@ -22,6 +22,7 @@
 //
 //
 
 
 import Foundation
 import Foundation
+import UniformTypeIdentifiers
 
 
 extension NCShareExtension {
 extension NCShareExtension {
 
 
@@ -89,7 +90,7 @@ extension NCShareExtension {
 
 
 class NCFilesExtensionHandler {
 class NCFilesExtensionHandler {
     var itemsProvider: [NSItemProvider] = []
     var itemsProvider: [NSItemProvider] = []
-    lazy var filesName: [String] = []
+    lazy var fileNames: [String] = []
     let dateFormatter: DateFormatter = {
     let dateFormatter: DateFormatter = {
         let formatter = DateFormatter()
         let formatter = DateFormatter()
         formatter.dateFormat = "yyyy-MM-dd HH-mm-ss-"
         formatter.dateFormat = "yyyy-MM-dd HH-mm-ss-"
@@ -102,20 +103,24 @@ class NCFilesExtensionHandler {
         var counter = 0
         var counter = 0
 
 
         self.itemsProvider = items.compactMap({ $0.attachments }).flatMap { $0.filter({
         self.itemsProvider = items.compactMap({ $0.attachments }).flatMap { $0.filter({
-            $0.hasItemConformingToTypeIdentifier(kUTTypeItem as String) || $0.hasItemConformingToTypeIdentifier("public.url")
+            $0.hasItemConformingToTypeIdentifier(UTType.item.identifier as String) || $0.hasItemConformingToTypeIdentifier("public.url")
         }) }
         }) }
 
 
         for (ix, provider) in itemsProvider.enumerated() {
         for (ix, provider) in itemsProvider.enumerated() {
             provider.loadItem(forTypeIdentifier: provider.typeIdentifier) { [self] item, error in
             provider.loadItem(forTypeIdentifier: provider.typeIdentifier) { [self] item, error in
                 defer {
                 defer {
                     counter += 1
                     counter += 1
-                    if counter == itemsProvider.count { completion(self.filesName) }
+                    if counter == itemsProvider.count { completion(self.fileNames) }
                 }
                 }
                 guard error == nil else { return }
                 guard error == nil else { return }
                 var originalName = (dateFormatter.string(from: Date())) + String(ix)
                 var originalName = (dateFormatter.string(from: Date())) + String(ix)
 
 
                 if let url = item as? URL, url.isFileURL, !url.lastPathComponent.isEmpty {
                 if let url = item as? URL, url.isFileURL, !url.lastPathComponent.isEmpty {
                     originalName = url.lastPathComponent
                     originalName = url.lastPathComponent
+
+                    if fileNames.contains(originalName), let incrementalNumber = CCUtility.getIncrementalNumber() {
+                        originalName = "\(url.deletingPathExtension().lastPathComponent) \(incrementalNumber).\(url.pathExtension)"
+                    }
                 }
                 }
 
 
                 var fileName: String?
                 var fileName: String?
@@ -131,7 +136,9 @@ class NCFilesExtensionHandler {
                 default: return
                 default: return
                 }
                 }
 
 
-                if let fileName = fileName, !filesName.contains(fileName) { filesName.append(fileName) }
+                if let fileName, !fileNames.contains(fileName) {
+                    fileNames.append(fileName)
+                }
             }
             }
         }
         }
     }
     }
@@ -140,8 +147,7 @@ class NCFilesExtensionHandler {
     func getItem(image: UIImage, fileName: String) -> String? {
     func getItem(image: UIImage, fileName: String) -> String? {
         var fileUrl = URL(fileURLWithPath: NSTemporaryDirectory() + fileName)
         var fileUrl = URL(fileURLWithPath: NSTemporaryDirectory() + fileName)
         if fileUrl.pathExtension.isEmpty { fileUrl.appendPathExtension("png") }
         if fileUrl.pathExtension.isEmpty { fileUrl.appendPathExtension("png") }
-        guard let pngImageData = image.pngData(),
-              (try? pngImageData.write(to: fileUrl, options: [.atomic])) != nil
+        guard let pngImageData = image.pngData(), (try? pngImageData.write(to: fileUrl, options: [.atomic])) != nil
         else { return nil }
         else { return nil }
         return fileUrl.lastPathComponent
         return fileUrl.lastPathComponent
     }
     }
@@ -151,7 +157,7 @@ class NCFilesExtensionHandler {
     func getItem(url: URL, fileName: String) -> String? {
     func getItem(url: URL, fileName: String) -> String? {
         var fileName = fileName
         var fileName = fileName
         guard url.isFileURL else {
         guard url.isFileURL else {
-            guard !filesName.contains(url.lastPathComponent) else { return nil }
+            guard !fileNames.contains(url.lastPathComponent) else { return nil }
             if !url.deletingPathExtension().lastPathComponent.isEmpty { fileName = url.deletingPathExtension().lastPathComponent }
             if !url.deletingPathExtension().lastPathComponent.isEmpty { fileName = url.deletingPathExtension().lastPathComponent }
             fileName += "." + (url.pathExtension.isEmpty ? "html" : url.pathExtension)
             fileName += "." + (url.pathExtension.isEmpty ? "html" : url.pathExtension)
             let filenamePath = NSTemporaryDirectory() + fileName
             let filenamePath = NSTemporaryDirectory() + fileName

+ 3 - 0
Share/NCShareExtension+NCDelegate.swift

@@ -76,6 +76,9 @@ extension NCShareExtension: NCEmptyDataSetDelegate, NCAccountRequestDelegate {
         }
         }
         self.activeAccount = activeAccount
         self.activeAccount = activeAccount
 
 
+        // CAPABILITIES
+        NCManageDatabase.shared.setCapabilities(account: account)
+
         // COLORS
         // COLORS
         NCBrandColor.shared.settingThemingColor(account: activeAccount.account)
         NCBrandColor.shared.settingThemingColor(account: activeAccount.account)
         NCBrandColor.shared.createUserColors()
         NCBrandColor.shared.createUserColors()

+ 1 - 1
Share/NCShareExtension.swift

@@ -83,7 +83,7 @@ class NCShareExtension: UIViewController {
         collectionView.register(UINib(nibName: "NCListCell", bundle: nil), forCellWithReuseIdentifier: "listCell")
         collectionView.register(UINib(nibName: "NCListCell", bundle: nil), forCellWithReuseIdentifier: "listCell")
         collectionView.collectionViewLayout = NCListLayout()
         collectionView.collectionViewLayout = NCListLayout()
 
 
-        collectionView.addSubview(refreshControl)
+        collectionView.refreshControl = refreshControl
         refreshControl.tintColor = NCBrandColor.shared.brandText
         refreshControl.tintColor = NCBrandColor.shared.brandText
         refreshControl.backgroundColor = .systemBackground
         refreshControl.backgroundColor = .systemBackground
         refreshControl.addTarget(self, action: #selector(reloadDatasource), for: .valueChanged)
         refreshControl.addTarget(self, action: #selector(reloadDatasource), for: .valueChanged)

+ 18 - 0
Sourcery/EnvVars.stencil

@@ -0,0 +1,18 @@
+//
+//  EnvVars.stencil.swift
+//  NextcloudIntegrationTests
+//
+//  Created by Milen on 31.05.23.
+//  Copyright © 2023 Marino Faggiana. All rights reserved.
+//
+
+import Foundation
+
+/**
+This is generated from the .env-vars file in the root directory. If there is an environment variable here that is needed and not filled, please look into this file.
+ */
+ public struct EnvVars {
+  static let testUser = "{{ argument.TEST_USER }}"
+  static let testAppPassword = "{{ argument.TEST_APP_PASSWORD }}"
+  static let testServerUrl = "{{ argument.TEST_SERVER_URL }}"
+}

BIN
Sourcery/bin/sourcery


+ 81 - 0
Tests/NextcloudIntegrationTests/FilesIntegrationTests.swift

@@ -0,0 +1,81 @@
+//
+//  NextcloudIntegrationTests.swift
+//  NextcloudIntegrationTests
+//
+//  Created by Milen Pivchev on 5/19/23.
+//  Copyright © 2023 Marino Faggiana. All rights reserved.
+//
+
+import XCTest
+import NextcloudKit
+@testable import Nextcloud
+
+final class FilesIntegrationTests: XCTestCase {
+    private let baseUrl = EnvVars.testServerUrl
+    private let user = EnvVars.testUser
+    private let userId = EnvVars.testUser
+    private let password = EnvVars.testAppPassword
+    private lazy var account = "\(userId) \(baseUrl)"
+
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
+
+    override func setUp() {
+        appDelegate.deleteAllAccounts()
+    }
+
+    func test_createReadDeleteFolder_withProperParams_shouldCreateReadDeleteFolder() throws {
+        let expectation = expectation(description: "Should finish last callback")
+
+        let folderName = "TestFolder10"
+        let serverUrl = "\(baseUrl)/remote.php/dav/files/\(userId)"
+        let serverUrlFileName = "\(serverUrl)/\(folderName)"
+
+        NextcloudKit.shared.setup(account: account, user: user, userId: userId, password: password, urlBase: baseUrl)
+
+        // Test creating folder
+        NCNetworking.shared.createFolder(fileName: folderName, serverUrl: serverUrl, account: account, urlBase: baseUrl, userId: userId, withPush: true) { error in
+            XCTAssertEqual(NKError.success.errorCode, error.errorCode)
+            XCTAssertEqual(NKError.success.errorDescription, error.errorDescription)
+
+            Thread.sleep(forTimeInterval: 0.2)
+
+            // Test reading folder, should exist
+            NCNetworking.shared.readFolder(serverUrl: serverUrlFileName, account: self.user) { account, metadataFolder, metadatas, metadatasUpdate, metadatasLocalUpdate, metadatasDelete, error in
+                XCTAssertEqual(self.account, account)
+                XCTAssertEqual(NKError.success.errorCode, error.errorCode)
+                XCTAssertEqual(NKError.success.errorDescription, error.errorDescription)
+                XCTAssertEqual(metadataFolder?.fileName, folderName)
+
+                // Check Realm directory, should exist
+                let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "serverUrl == %@", serverUrlFileName))
+                XCTAssertNotNil(directory)
+
+                Thread.sleep(forTimeInterval: 0.2)
+
+                Task {
+                    // Test deleting folder
+                    await _ = NCNetworking.shared.deleteMetadata(metadataFolder!, onlyLocalCache: false)
+
+                    XCTAssertEqual(NKError.success.errorCode, error.errorCode)
+                    XCTAssertEqual(NKError.success.errorDescription, error.errorDescription)
+
+                    try await Task.sleep(for: .milliseconds(200))
+
+                    // Test reading folder, should NOT exist
+                    NCNetworking.shared.readFolder(serverUrl: serverUrlFileName, account: self.user) { account, metadataFolder, metadatas, metadatasUpdate, metadatasLocalUpdate, metadatasDelete, error in
+                        defer { expectation.fulfill() }
+
+                        XCTAssertEqual(404, error.errorCode)
+                        XCTAssertNil(metadataFolder?.fileName)
+
+                        // Check Realm directory, should NOT exist
+                        let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "serverUrl == %@", serverUrlFileName))
+                        XCTAssertNil(directory)
+                    }
+                }
+            }
+        }
+        
+        waitForExpectations(timeout: 100)
+    }
+}

+ 83 - 0
Tests/NextcloudIntegrationTests/LoginIntegrationTests.swift

@@ -0,0 +1,83 @@
+//
+//  NextcloudIntegrationTests.swift
+//  NextcloudIntegrationTests
+//
+//  Created by Milen Pivchev on 5/19/23.
+//  Copyright © 2023 Marino Faggiana. All rights reserved.
+//
+
+import XCTest
+import NextcloudKit
+@testable import Nextcloud
+
+final class LoginIntegrationTests: XCTestCase {
+    private let baseUrl = EnvVars.testServerUrl
+    private let user = EnvVars.testUser
+    private let userId = EnvVars.testUser
+    private let password = EnvVars.testAppPassword
+    private lazy var account = "\(userId) \(baseUrl)"
+
+    private let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
+
+    override func setUp() {
+        appDelegate.deleteAllAccounts()
+    }
+
+    func test_createReadDeleteFolder_withProperParams_shouldCreateReadDeleteFolder() throws {
+        let expectation = expectation(description: "Should finish last callback")
+
+        let folderName = "TestFolder10"
+        let serverUrl = "\(baseUrl)/remote.php/dav/files/\(userId)"
+        let serverUrlFileName = "\(serverUrl)/\(folderName)"
+
+        NextcloudKit.shared.setup(account: account, user: user, userId: userId, password: password, urlBase: baseUrl)
+
+        // Test creating folder
+        NCNetworking.shared.createFolder(fileName: folderName, serverUrl: serverUrl, account: account, urlBase: baseUrl, userId: userId, withPush: true) { error in
+            XCTAssertEqual(NKError.success.errorCode, error.errorCode)
+            XCTAssertEqual(NKError.success.errorDescription, error.errorDescription)
+
+            Thread.sleep(forTimeInterval: 0.2)
+
+            // Test reading folder, should exist
+            NCNetworking.shared.readFolder(serverUrl: serverUrlFileName, account: self.user) { account, metadataFolder, metadatas, metadatasUpdate, metadatasLocalUpdate, metadatasDelete, error in
+                XCTAssertEqual(self.account, account)
+                XCTAssertEqual(NKError.success.errorCode, error.errorCode)
+                XCTAssertEqual(NKError.success.errorDescription, error.errorDescription)
+                XCTAssertEqual(metadataFolder?.fileName, folderName)
+
+                // Check Realm directory, should exist
+                let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "serverUrl == %@", serverUrlFileName))
+                XCTAssertNotNil(directory)
+
+                Thread.sleep(forTimeInterval: 0.2)
+
+                Task {
+                    // Test deleting folder
+                    await _ = NCNetworking.shared.deleteMetadata(metadataFolder!, onlyLocalCache: false)
+
+                    XCTAssertEqual(NKError.success.errorCode, error.errorCode)
+                    XCTAssertEqual(NKError.success.errorDescription, error.errorDescription)
+
+                    try await Task.sleep(for: .milliseconds(200))
+
+                    // Test reading folder, should NOT exist
+                    NCNetworking.shared.readFolder(serverUrl: serverUrlFileName, account: self.user) { account, metadataFolder, metadatas, metadatasUpdate, metadatasLocalUpdate, metadatasDelete, error in
+                        defer { expectation.fulfill() }
+
+                        XCTAssertEqual(404, error.errorCode)
+                        XCTAssertNil(metadataFolder?.fileName)
+
+                        // Check Realm directory, should NOT exist
+                        let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "serverUrl == %@", serverUrlFileName))
+                        XCTAssertNil(directory)
+                    }
+                }
+
+
+            }
+        }
+        
+        waitForExpectations(timeout: 100)
+    }
+}

+ 18 - 0
Tests/NextcloudSnapshotTests/Extensions/SwiftUIView+Extensions.swift

@@ -0,0 +1,18 @@
+//
+//  SwiftUIView+Extensions.swift
+//  Nextcloud
+//
+//  Created by Milen on 06.06.23.
+//  Copyright © 2023 Marino Faggiana. All rights reserved.
+//
+
+import Foundation
+import SwiftUI
+
+extension SwiftUI.View {
+    func toVC() -> UIViewController {
+        let vc = UIHostingController (rootView: self)
+        vc.view.frame = UIScreen.main.bounds
+        return vc
+    }
+}

+ 24 - 0
Tests/NextcloudSnapshotTests/NextcloudSnapshotTests.swift

@@ -0,0 +1,24 @@
+//
+//  NextcloudSnapshotTests.swift
+//  NextcloudSnapshotTests
+//
+//  Created by Milen on 06.06.23.
+//  Copyright © 2023 Marino Faggiana. All rights reserved.
+//
+
+import XCTest
+import SnapshotTesting
+import SnapshotTestingHEIC
+import PreviewSnapshotsTesting
+import SwiftUI
+@testable import Nextcloud
+
+final class NextcloudSnapshotTests: XCTestCase {
+    func test_HUDView() {
+        HUDView_Previews.snapshots.assertSnapshots(as: .imageHEIC)
+    }
+
+    func test_CapalitiesView() {
+        NCCapabilitiesView_Previews.snapshots.assertSnapshots(as: .imageHEIC)
+    }
+}

BIN
Tests/NextcloudSnapshotTests/__Snapshots__/NextcloudSnapshotTests/test_CapalitiesView.DefaultPreviewConfiguration.heic


BIN
Tests/NextcloudSnapshotTests/__Snapshots__/NextcloudSnapshotTests/test_HUDView.DefaultPreviewConfiguration.heic


+ 35 - 0
Tests/NextcloudUITests/BaseUIXCTestCase.swift

@@ -0,0 +1,35 @@
+//
+//  BaseUIXCTestCase.swift
+//  NextcloudUITests
+//
+//  Created by Milen on 20.06.23.
+//  Copyright © 2023 Marino Faggiana. All rights reserved.
+//
+
+import XCTest
+
+class BaseUIXCTestCase: XCTestCase {
+    let timeoutSeconds: Double = 100
+
+    override final class var runsForEachTargetApplicationUIConfiguration: Bool {
+        false
+    }
+
+    internal func waitForEnabled(object: Any?) {
+        let predicate = NSPredicate(format: "enabled == true")
+        expectation(for: predicate, evaluatedWith: object, handler: nil)
+        waitForExpectations(timeout: timeoutSeconds, handler: nil)
+    }
+
+    internal func waitForHittable(object: Any?) {
+        let predicate = NSPredicate(format: "hittable == true")
+        expectation(for: predicate, evaluatedWith: object, handler: nil)
+        waitForExpectations(timeout: timeoutSeconds, handler: nil)
+    }
+
+    internal func waitForEnabledAndHittable(object: Any?) {
+        waitForEnabled(object: object)
+        waitForHittable(object: object)
+    }
+}
+

+ 64 - 0
Tests/NextcloudUITests/LoginUITests.swift

@@ -0,0 +1,64 @@
+//
+//  NextcloudUITests.swift
+//  NextcloudUITests
+//
+//  Created by Milen Pivchev on 5/19/23.
+//  Copyright © 2023 Marino Faggiana. All rights reserved.
+//
+
+import XCTest
+
+final class LoginUITests: BaseUIXCTestCase {
+    private let baseUrl = EnvVars.testServerUrl
+    private let user = EnvVars.testUser
+    private let userId = EnvVars.testUser
+    private let password = EnvVars.testAppPassword
+    private lazy var account = "\(userId) \(baseUrl)"
+
+    let app = XCUIApplication()
+
+    override func setUp() {
+        app.launchArguments += ["UI_TESTING"]
+    }
+
+    func test_logIn_withProperParams_shouldLogInAndGoToHomeScreen() throws {
+        app.launch()
+
+        let loginButton = app.buttons["Log in"]
+        XCTAssert(loginButton.waitForExistence(timeout: timeoutSeconds))
+        loginButton.tap()
+
+        let serverAddressHttpsTextField = app.textFields["Server address https:// …"]
+        serverAddressHttpsTextField.tap()
+        serverAddressHttpsTextField.typeText(baseUrl)
+        let button = app.windows.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.children(matching: .button).element(boundBy: 0)
+        button.tap()
+
+        let webViewsQuery = app.webViews.webViews.webViews
+        let loginButton2 = webViewsQuery/*@START_MENU_TOKEN@*/.buttons["Log in"]/*[[".otherElements.matching(identifier: \"Nextcloud\")",".otherElements[\"main\"].buttons[\"Log in\"]",".buttons[\"Log in\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/
+        XCTAssert(loginButton2.waitForExistence(timeout: timeoutSeconds))
+        waitForEnabledAndHittable(object: loginButton2)
+        loginButton2.tap()
+
+        let element = webViewsQuery/*@START_MENU_TOKEN@*/.otherElements["main"]/*[[".otherElements[\"Login – Nextcloud\"].otherElements[\"main\"]",".otherElements[\"main\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.children(matching: .other).element(boundBy: 1)
+        let usernameTextField = element.children(matching: .other).element(boundBy: 2).children(matching: .textField).element
+        XCTAssert(usernameTextField.waitForExistence(timeout: timeoutSeconds))
+        usernameTextField.tap()
+        usernameTextField.typeText(user)
+        let passwordTextField = element.children(matching: .other).element(boundBy: 4).children(matching: .secureTextField).element
+        passwordTextField.tap()
+        passwordTextField.typeText(user)
+        let loginButton3 = webViewsQuery/*@START_MENU_TOKEN@*/.buttons["Log in"]/*[[".otherElements[\"Login – Nextcloud\"]",".otherElements[\"main\"].buttons[\"Log in\"]",".buttons[\"Log in\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/
+        XCTAssert(loginButton3.waitForExistence(timeout: timeoutSeconds))
+        loginButton3.tap()
+
+        let grantAccessButton = webViewsQuery/*@START_MENU_TOKEN@*/.buttons["Grant access"]/*[[".otherElements.matching(identifier: \"Nextcloud\")",".otherElements[\"main\"].buttons[\"Grant access\"]",".buttons[\"Grant access\"]"],[[[-1,2],[-1,1],[-1,0,1]],[[-1,2],[-1,1]]],[0]]@END_MENU_TOKEN@*/
+        XCTAssert(grantAccessButton.waitForExistence(timeout: timeoutSeconds))
+        waitForEnabledAndHittable(object: grantAccessButton)
+        grantAccessButton.tap()
+
+        // Check if we are in the home screen
+        XCTAssert(app.navigationBars["Nextcloud"].waitForExistence(timeout: timeoutSeconds))
+        XCTAssert(app.tabBars["Tab Bar"].waitForExistence(timeout: timeoutSeconds))
+    }
+}

+ 1 - 1
NextcloudTests/NextcloudTests.swift → Tests/NextcloudUnitTests/NextcloudUnitTests.swift

@@ -8,7 +8,7 @@
 
 
 import XCTest
 import XCTest
 
 
-class NextcloudTests: XCTestCase {
+class NextcloudUnitTests: XCTestCase {
 
 
     override func setUpWithError() throws {
     override func setUpWithError() throws {
         // Put setup code here. This method is called before the invocation of each test method in the class.
         // Put setup code here. This method is called before the invocation of each test method in the class.

+ 49 - 0
create-docker-test-server.sh

@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+#This script creates a testable Docker enviroment of the Nextcloud server, and is used by the CI for tests.
+
+container_name="nextcloud_test"
+port=8080
+server_url="http://localhost:${port}"
+user="admin"
+
+docker run --rm -d --name $container_name -p $port:80 ghcr.io/juliushaertl/nextcloud-dev-php80:latest
+
+timeout=300
+elapsed=0
+
+echo "Waiting for server..."
+
+sleep 2
+
+while true; do
+    content=$(curl -s $server_url/status.php)
+
+    if [[ $content == *"installed\":true"* ]]; then
+        break
+    fi
+
+    elapsed=$((elapsed + 1))
+
+    if [ $elapsed -ge $timeout ]; then
+        echo "No success after $timeout seconds."
+        exit 1
+    fi
+
+    sleep 1
+done
+
+echo "Server is installed."
+echo "Exporting env vars..."
+
+sleep 2
+
+password=$(docker exec -e NC_PASS=$user $container_name sudo -E -u www-data php /var/www/html/occ user:add-app-password $user --password-from-env | tail -1)
+
+export TEST_APP_PASSWORD=$password
+export TEST_SERVER_URL=$server_url
+export TEST_USER=$user
+
+echo "TEST_SERVER_URL: ${TEST_SERVER_URL}"
+echo "TEST_USER: ${TEST_USER}"
+echo "TEST_APP_PASSWORD: ${TEST_APP_PASSWORD}"
+echo "Env vars exported."

+ 36 - 0
iOSClient/AppDelegate.swift

@@ -59,7 +59,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
 
     private var privacyProtectionWindow: UIWindow?
     private var privacyProtectionWindow: UIWindow?
 
 
+    var isUiTestingEnabled: Bool {
+         get {
+             return ProcessInfo.processInfo.arguments.contains("UI_TESTING")
+         }
+     }
+
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
+        if isUiTestingEnabled {
+            deleteAllAccounts()
+        }
 
 
         NCSettingsBundleHelper.checkAndExecuteSettings(delay: 0)
         NCSettingsBundleHelper.checkAndExecuteSettings(delay: 0)
 
 
@@ -625,6 +634,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         }
         }
     }
     }
 
 
+    @objc func deleteAllAccounts() {
+        let accounts = NCManageDatabase.shared.getAccounts()
+        accounts?.forEach({ account in
+            deleteAccount(account, wipe: true)
+        })
+    }
+
     @objc func changeAccount(_ account: String) {
     @objc func changeAccount(_ account: String) {
 
 
         NCManageDatabase.shared.setAccountActive(account)
         NCManageDatabase.shared.setAccountActive(account)
@@ -931,6 +947,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
                 }
                 }
             }
             }
             return true
             return true
+
+        /*
+         Example:
+         nextcloud://open-and-switch-account?user=marinofaggiana&url=https://cloud.nextcloud.com
+         */
+
+        } else if !account.isEmpty && scheme == NCGlobal.shared.appScheme && action == "open-and-switch-account" {
+            guard let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return false }
+            let queryItems = urlComponents.queryItems
+
+            guard let userScheme = CCUtility.value(forKey: "user", fromQueryItems: queryItems) else { return false }
+            guard let urlScheme = CCUtility.value(forKey: "url", fromQueryItems: queryItems) else { return false }
+
+            // If the account doesn't exist, return false which will open the app without switching
+            if getMatchedAccount(userId: userScheme, url: urlScheme) == nil {
+                return false
+            }
+
+            // Otherwise open the app and switch accounts
+            return true
         } else {
         } else {
             let applicationHandle = NCApplicationHandle()
             let applicationHandle = NCApplicationHandle()
             let isHandled = applicationHandle.applicationOpenURL(url)
             let isHandled = applicationHandle.applicationOpenURL(url)

+ 72 - 59
iOSClient/Diagnostics/NCCapabilitiesView.swift

@@ -8,6 +8,7 @@
 
 
 import SwiftUI
 import SwiftUI
 import NextcloudKit
 import NextcloudKit
+import PreviewSnapshots
 
 
 @objc class NCHostingCapabilitiesView: NSObject {
 @objc class NCHostingCapabilitiesView: NSObject {
 
 
@@ -35,70 +36,62 @@ class NCCapabilitiesViewOO: ObservableObject {
     @Published var homeServer = ""
     @Published var homeServer = ""
 
 
     init() {
     init() {
+        guard let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return }
+        var textEditor = false
+        var onlyofficeEditors = false
 
 
-        if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" {
-            capabililies = [Capability(text: "Collabora", image: UIImage(named: "collabora")!, resize: true, available: true),
-                            Capability(text: "XXX site", image: UIImage(systemName: "lock.shield")!, resize: false, available: false)
-            ]
-            homeServer = "https://cloud.nextcloud.com/remote.php.dav/files/marino/"
-        } else {
-            guard let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return }
-            var textEditor = false
-            var onlyofficeEditors = false
-
-            if let image = UIImage(named: "share") {
-                capabililies.append(Capability(text: "File sharing", image: image, resize: true, available: NCGlobal.shared.capabilityFileSharingApiEnabled))
-            }
-            if let image = UIImage(systemName: "network") {
-                capabililies.append(Capability(text: "External site", image: image, resize: false, available: NCGlobal.shared.capabilityExternalSites))
-            }
-            if let image = UIImage(systemName: "lock") {
-                capabililies.append(Capability(text: "End-to-End Encryption", image: image, resize: false, available: NCGlobal.shared.capabilityE2EEEnabled))
-            }
-            if let image = UIImage(systemName: "bolt") {
-                capabililies.append(Capability(text: "Activity", image: image, resize: false, available: !NCGlobal.shared.capabilityActivity.isEmpty))
-            }
-            if let image = UIImage(systemName: "bell") {
-                capabililies.append(Capability(text: "Notification", image: image, resize: false, available: !NCGlobal.shared.capabilityNotification.isEmpty))
-            }
-            if let image = UIImage(systemName: "trash") {
-                capabililies.append(Capability(text: "Deleted files", image: image, resize: false, available: NCGlobal.shared.capabilityFilesUndelete))
-            }
+        if let image = UIImage(named: "share") {
+            capabililies.append(Capability(text: "File sharing", image: image, resize: true, available: NCGlobal.shared.capabilityFileSharingApiEnabled))
+        }
+        if let image = UIImage(systemName: "network") {
+            capabililies.append(Capability(text: "External site", image: image, resize: false, available: NCGlobal.shared.capabilityExternalSites))
+        }
+        if let image = UIImage(systemName: "lock") {
+            capabililies.append(Capability(text: "End-to-End Encryption", image: image, resize: false, available: NCGlobal.shared.capabilityE2EEEnabled))
+        }
+        if let image = UIImage(systemName: "bolt") {
+            capabililies.append(Capability(text: "Activity", image: image, resize: false, available: !NCGlobal.shared.capabilityActivity.isEmpty))
+        }
+        if let image = UIImage(systemName: "bell") {
+            capabililies.append(Capability(text: "Notification", image: image, resize: false, available: !NCGlobal.shared.capabilityNotification.isEmpty))
+        }
+        if let image = UIImage(systemName: "trash") {
+            capabililies.append(Capability(text: "Deleted files", image: image, resize: false, available: NCGlobal.shared.capabilityFilesUndelete))
+        }
 
 
-            if let editors = NCManageDatabase.shared.getDirectEditingEditors(account: activeAccount.account) {
-                for editor in editors {
-                    if editor.editor == NCGlobal.shared.editorText {
-                        textEditor = true
-                    } else if editor.editor == NCGlobal.shared.editorOnlyoffice {
-                        onlyofficeEditors = true
-                    }
+        if let editors = NCManageDatabase.shared.getDirectEditingEditors(account: activeAccount.account) {
+            for editor in editors {
+                if editor.editor == NCGlobal.shared.editorText {
+                    textEditor = true
+                } else if editor.editor == NCGlobal.shared.editorOnlyoffice {
+                    onlyofficeEditors = true
                 }
                 }
             }
             }
+        }
 
 
-            if let image = UIImage(systemName: "doc.text") {
-                capabililies.append(Capability(text: "Text", image: image, resize: false, available: textEditor))
-            }
-            if let image = UIImage(named: "onlyoffice") {
-                capabililies.append(Capability(text: "ONLYOFFICE", image: image, resize: true, available: onlyofficeEditors))
-            }
-            if let image = UIImage(named: "collabora") {
-                capabililies.append(Capability(text: "Collabora", image: image, resize: true, available: !NCGlobal.shared.capabilityRichdocumentsMimetypes.isEmpty))
-            }
-            if let image = UIImage(systemName: "moon") {
-                capabililies.append(Capability(text: "User Status", image: image, resize: false, available: NCGlobal.shared.capabilityUserStatusEnabled))
-            }
-            if let image = UIImage(systemName: "ellipsis.bubble") {
-                capabililies.append(Capability(text: "Comments", image: image, resize: false, available: NCGlobal.shared.capabilityFilesComments))
-            }
-            if let image = UIImage(systemName: "lock") {
-                capabililies.append(Capability(text: "Lock file", image: image, resize: false, available: !NCGlobal.shared.capabilityFilesLockVersion.isEmpty))
-            }
-            if let image = UIImage(systemName: "person.2") {
-                capabililies.append(Capability(text: "Group folders", image: image, resize: false, available: NCGlobal.shared.capabilityGroupfoldersEnabled))
-            }
-
-            homeServer = NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, userId: activeAccount.userId) + "/"
+        if let image = UIImage(systemName: "doc.text") {
+            capabililies.append(Capability(text: "Text", image: image, resize: false, available: textEditor))
+        }
+        if let image = UIImage(named: "onlyoffice") {
+            capabililies.append(Capability(text: "ONLYOFFICE", image: image, resize: true, available: onlyofficeEditors))
+        }
+        if let image = UIImage(named: "collabora") {
+            capabililies.append(Capability(text: "Collabora", image: image, resize: true, available: !NCGlobal.shared.capabilityRichdocumentsMimetypes.isEmpty))
+        }
+        if let image = UIImage(systemName: "moon") {
+            capabililies.append(Capability(text: "User Status", image: image, resize: false, available: NCGlobal.shared.capabilityUserStatusEnabled))
         }
         }
+        if let image = UIImage(systemName: "ellipsis.bubble") {
+            capabililies.append(Capability(text: "Comments", image: image, resize: false, available: NCGlobal.shared.capabilityFilesComments))
+        }
+        if let image = UIImage(systemName: "lock") {
+            capabililies.append(Capability(text: "Lock file", image: image, resize: false, available: !NCGlobal.shared.capabilityFilesLockVersion.isEmpty))
+        }
+        if let image = UIImage(systemName: "person.2") {
+            capabililies.append(Capability(text: "Group folders", image: image, resize: false, available: NCGlobal.shared.capabilityGroupfoldersEnabled))
+        }
+
+        homeServer = NCUtilityFileSystem.shared.getHomeServer(urlBase: activeAccount.urlBase, userId: activeAccount.userId) + "/"
     }
     }
 }
 }
 
 
@@ -175,6 +168,26 @@ struct NCCapabilitiesView: View {
 
 
 struct NCCapabilitiesView_Previews: PreviewProvider {
 struct NCCapabilitiesView_Previews: PreviewProvider {
     static var previews: some View {
     static var previews: some View {
-        NCCapabilitiesView(capabilitiesStatus: NCCapabilitiesViewOO())
+        snapshots.previews.previewLayout(.device)
     }
     }
+
+    static var snapshots: PreviewSnapshots<String> {
+        PreviewSnapshots(
+            configurations: [
+                .init(name: NCGlobal.shared.defaultSnapshotConfiguration, state: "")
+            ],
+            configure: { _ in
+                NCCapabilitiesView(capabilitiesStatus: getCapabilitiesViewOOForPreview()).padding(.top, 20).frameForPreview()
+            })
+    }
+}
+
+func getCapabilitiesViewOOForPreview() -> NCCapabilitiesViewOO {
+    let capabilitiesViewOO = NCCapabilitiesViewOO()
+    capabilitiesViewOO.capabililies = [
+        NCCapabilitiesViewOO.Capability(text: "Collabora", image: UIImage(named: "collabora")!, resize: true, available: true),
+        NCCapabilitiesViewOO.Capability(text: "XXX site", image: UIImage(systemName: "lock.shield")!, resize: false, available: false)
+    ]
+    capabilitiesViewOO.homeServer = "https://cloud.nextcloud.com/remote.php.dav/files/marino/"
+    return capabilitiesViewOO
 }
 }

+ 21 - 23
iOSClient/EmptyView/NCEmptyDataSet.swift

@@ -49,36 +49,30 @@ class NCEmptyDataSet: NSObject {
     init(view: UIView, offset: CGFloat = 0, delegate: NCEmptyDataSetDelegate?) {
     init(view: UIView, offset: CGFloat = 0, delegate: NCEmptyDataSetDelegate?) {
         super.init()
         super.init()
 
 
-        if let emptyView = UINib(nibName: "NCEmptyView", bundle: nil).instantiate(withOwner: self, options: nil).first as? NCEmptyView {
+        guard let emptyView = NCEmptyView.fromNib().instantiate(withOwner: self, options: nil).first as? NCEmptyView else { return }
 
 
-            self.delegate = delegate
-            self.emptyView = emptyView
+        self.delegate = delegate
+        self.emptyView = emptyView
 
 
-            emptyView.isHidden = true
-            emptyView.translatesAutoresizingMaskIntoConstraints = false
+        emptyView.isHidden = true
+        emptyView.translatesAutoresizingMaskIntoConstraints = false
 
 
-//            emptyView.backgroundColor = .red
-//            emptyView.isHidden = false
+        view.addSubview(emptyView)
 
 
-            emptyView.emptyTitle.sizeToFit()
-            emptyView.emptyDescription.sizeToFit()
+        emptyView.widthAnchor.constraint(equalToConstant: 350).isActive = true
+        emptyView.heightAnchor.constraint(equalToConstant: 250).isActive = true
 
 
-            view.addSubview(emptyView)
-
-            emptyView.widthAnchor.constraint(equalToConstant: 350).isActive = true
-            emptyView.heightAnchor.constraint(equalToConstant: 250).isActive = true
+        if let view = view.superview {
+            centerXAnchor = emptyView.centerXAnchor.constraint(equalTo: view.centerXAnchor)
+            centerYAnchor = emptyView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: offset)
+        } else {
+            centerXAnchor = emptyView.centerXAnchor.constraint(equalTo: view.centerXAnchor)
+            centerYAnchor = emptyView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: offset)
+        }
 
 
-            if let view = view.superview {
-                centerXAnchor = emptyView.centerXAnchor.constraint(equalTo: view.centerXAnchor)
-                centerYAnchor = emptyView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: offset)
-            } else {
-                centerXAnchor = emptyView.centerXAnchor.constraint(equalTo: view.centerXAnchor)
-                centerYAnchor = emptyView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: offset)
-            }
+        centerXAnchor?.isActive = true
+        centerYAnchor?.isActive = true
 
 
-            centerXAnchor?.isActive = true
-            centerYAnchor?.isActive = true
-        }
     }
     }
 
 
     func setOffset(_ offset: CGFloat) {
     func setOffset(_ offset: CGFloat) {
@@ -124,6 +118,10 @@ public class NCEmptyView: UIView {
     @IBOutlet weak var emptyTitle: UILabel!
     @IBOutlet weak var emptyTitle: UILabel!
     @IBOutlet weak var emptyDescription: UILabel!
     @IBOutlet weak var emptyDescription: UILabel!
 
 
+    static func fromNib() -> UINib {
+        return UINib(nibName: "NCEmptyView", bundle: nil)
+    }
+
     public override func awakeFromNib() {
     public override func awakeFromNib() {
         super.awakeFromNib()
         super.awakeFromNib()
 
 

+ 21 - 17
iOSClient/EmptyView/NCEmptyView.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
-    <device id="retina3_5" orientation="portrait" appearance="light"/>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina6_72" orientation="landscape" appearance="light"/>
     <dependencies>
     <dependencies>
         <deployment identifier="iOS"/>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -12,24 +12,20 @@
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
         <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
         <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
         <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="NCEmptyView" customModule="Nextcloud" customModuleProvider="target">
         <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="NCEmptyView" customModule="Nextcloud" customModuleProvider="target">
-            <rect key="frame" x="0.0" y="0.0" width="350" height="250"/>
+            <rect key="frame" x="0.0" y="0.0" width="422" height="475"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
             <subviews>
                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="W3d-Us-kU4">
                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="W3d-Us-kU4">
-                    <rect key="frame" x="100" y="0.0" width="150" height="150"/>
+                    <rect key="frame" x="136" y="20" width="150" height="75"/>
                     <constraints>
                     <constraints>
-                        <constraint firstAttribute="height" constant="150" id="A8B-y7-Fre"/>
+                        <constraint firstAttribute="height" constant="150" id="A8B-y7-Fre">
+                            <variation key="heightClass=compact" constant="75"/>
+                        </constraint>
                         <constraint firstAttribute="width" constant="150" id="g0C-P6-l3d"/>
                         <constraint firstAttribute="width" constant="150" id="g0C-P6-l3d"/>
                     </constraints>
                     </constraints>
                 </imageView>
                 </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="20" y="180" width="310" 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="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D4p-sI-mNB">
                 <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="D4p-sI-mNB">
-                    <rect key="frame" x="20" y="224" width="310" height="17"/>
+                    <rect key="frame" x="79" y="135" width="264" height="17"/>
                     <constraints>
                     <constraints>
                         <constraint firstAttribute="height" relation="lessThanOrEqual" constant="50" id="u7B-jW-bWI"/>
                         <constraint firstAttribute="height" relation="lessThanOrEqual" constant="50" id="u7B-jW-bWI"/>
                     </constraints>
                     </constraints>
@@ -37,18 +33,26 @@
                     <color key="textColor" systemColor="systemGrayColor"/>
                     <color key="textColor" systemColor="systemGrayColor"/>
                     <nil key="highlightedColor"/>
                     <nil key="highlightedColor"/>
                 </label>
                 </label>
+                <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="79" y="103" width="264" 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>
             </subviews>
             </subviews>
             <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
             <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
             <constraints>
             <constraints>
                 <constraint firstItem="crs-DO-owR" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="CMU-Tp-bUM"/>
                 <constraint firstItem="crs-DO-owR" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="CMU-Tp-bUM"/>
-                <constraint firstItem="W3d-Us-kU4" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" id="Fyb-so-iAw"/>
                 <constraint firstItem="D4p-sI-mNB" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="egV-G4-wax"/>
                 <constraint firstItem="D4p-sI-mNB" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="20" id="egV-G4-wax"/>
                 <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="crs-DO-owR" secondAttribute="trailing" constant="20" id="hHl-iN-Gev"/>
                 <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="crs-DO-owR" secondAttribute="trailing" constant="20" id="hHl-iN-Gev"/>
-                <constraint firstItem="crs-DO-owR" firstAttribute="top" secondItem="W3d-Us-kU4" secondAttribute="bottom" constant="30" id="hLN-L6-0gH"/>
+                <constraint firstItem="crs-DO-owR" firstAttribute="top" secondItem="W3d-Us-kU4" secondAttribute="bottom" constant="8" id="hLN-L6-0gH"/>
                 <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="D4p-sI-mNB" secondAttribute="trailing" constant="20" id="imv-AK-mqu"/>
                 <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="D4p-sI-mNB" secondAttribute="trailing" constant="20" id="imv-AK-mqu"/>
                 <constraint firstItem="W3d-Us-kU4" firstAttribute="centerX" secondItem="vUN-kp-3ea" secondAttribute="centerX" id="kma-1Q-c3Q"/>
                 <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"/>
+                <constraint firstItem="W3d-Us-kU4" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" id="uOy-F7-KNu">
+                    <variation key="heightClass=compact" constant="20"/>
+                </constraint>
+                <constraint firstItem="D4p-sI-mNB" firstAttribute="top" secondItem="crs-DO-owR" secondAttribute="bottom" constant="8" id="zbi-5P-raN"/>
             </constraints>
             </constraints>
             <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
             <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
             <connections>
             <connections>
@@ -56,7 +60,7 @@
                 <outlet property="emptyImage" destination="W3d-Us-kU4" id="xtd-nV-OUc"/>
                 <outlet property="emptyImage" destination="W3d-Us-kU4" id="xtd-nV-OUc"/>
                 <outlet property="emptyTitle" destination="crs-DO-owR" id="IkU-6d-P64"/>
                 <outlet property="emptyTitle" destination="crs-DO-owR" id="IkU-6d-P64"/>
             </connections>
             </connections>
-            <point key="canvasLocation" x="-146.25" y="32.5"/>
+            <point key="canvasLocation" x="-86.956521739130437" y="111.49553571428571"/>
         </view>
         </view>
     </objects>
     </objects>
     <resources>
     <resources>

+ 0 - 0
iOSClient/Extensions/Optional+Extensions.swift → iOSClient/Extensions/Optional+Extension.swift


+ 1 - 1
iOSClient/Extensions/PHAsset+Extension.swift

@@ -15,7 +15,7 @@ extension PHAsset {
             return resource.originalFilename as NSString
             return resource.originalFilename as NSString
         } else {
         } else {
             return self.value(forKey: "filename") as? NSString
             return self.value(forKey: "filename") as? NSString
-            ?? ("IMG_" + CCUtility.getIncrementalNumber() + getExtension()) as NSString 
+            ?? ("IMG_" + CCUtility.getIncrementalNumber() + getExtension()) as NSString
         }
         }
     }
     }
 
 

+ 6 - 2
iOSClient/Extensions/UIImage+Extension.swift

@@ -116,10 +116,14 @@ extension UIImage {
     }
     }
 
 
     @objc func image(color: UIColor, size: CGFloat) -> UIImage {
     @objc func image(color: UIColor, size: CGFloat) -> UIImage {
+        return image(color: color, width: size, height: size)
+    }
+
+    @objc func image(color: UIColor, width: CGFloat, height: CGFloat) -> UIImage {
 
 
-        let size = CGSize(width: size, height: size)
+        let size = CGSize(width: width, height: height)
 
 
-        UIGraphicsBeginImageContextWithOptions(size, false, self.scale)
+        UIGraphicsBeginImageContextWithOptions(.init(width: width, height: height), false, self.scale)
         color.setFill()
         color.setFill()
 
 
         let context = UIGraphicsGetCurrentContext()
         let context = UIGraphicsGetCurrentContext()

+ 6 - 1
iOSClient/Extensions/View+Extension.swift

@@ -24,8 +24,13 @@
 import SwiftUI
 import SwiftUI
 
 
 extension View {
 extension View {
-
     func complexModifier<V: View>(@ViewBuilder _ closure: (Self) -> V) -> some View {
     func complexModifier<V: View>(@ViewBuilder _ closure: (Self) -> V) -> some View {
         closure(self)
         closure(self)
     }
     }
+
+    /// Use this on preview views that are used in snapshot testing. It prevents the snapashot library from complaining that the view has a size of 0
+    /// Check: https://github.com/pointfreeco/swift-snapshot-testing/issues/738
+    func frameForPreview() -> some View {
+        return frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
+    }
 }
 }

+ 0 - 1
iOSClient/Favorites/NCFavorite.swift

@@ -34,7 +34,6 @@ class NCFavorite: NCCollectionViewCommon {
         titleCurrentFolder = NSLocalizedString("_favorites_", comment: "")
         titleCurrentFolder = NSLocalizedString("_favorites_", comment: "")
         layoutKey = NCGlobal.shared.layoutViewFavorite
         layoutKey = NCGlobal.shared.layoutViewFavorite
         enableSearchBar = false
         enableSearchBar = false
-        headerMenuButtonsCommand = false
         headerMenuButtonsView = true
         headerMenuButtonsView = true
         headerRichWorkspaceDisable = true
         headerRichWorkspaceDisable = true
         emptyImage = UIImage(named: "star.fill")?.image(color: NCBrandColor.shared.yellowFavorite, size: UIScreen.main.bounds.width)
         emptyImage = UIImage(named: "star.fill")?.image(color: NCBrandColor.shared.yellowFavorite, size: UIScreen.main.bounds.width)

+ 0 - 1
iOSClient/Files/NCFiles.swift

@@ -38,7 +38,6 @@ class NCFiles: NCCollectionViewCommon {
         titleCurrentFolder = NCBrandOptions.shared.brand
         titleCurrentFolder = NCBrandOptions.shared.brand
         layoutKey = NCGlobal.shared.layoutViewFiles
         layoutKey = NCGlobal.shared.layoutViewFiles
         enableSearchBar = true
         enableSearchBar = true
-        headerMenuButtonsCommand = true
         headerMenuButtonsView = true
         headerMenuButtonsView = true
         headerRichWorkspaceDisable = false
         headerRichWorkspaceDisable = false
         emptyImage = UIImage(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width)
         emptyImage = UIImage(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width)

+ 12 - 1
iOSClient/GUI/HUDView.swift

@@ -22,6 +22,7 @@
 //
 //
 
 
 import SwiftUI
 import SwiftUI
+import PreviewSnapshots
 
 
 struct HUDView: View {
 struct HUDView: View {
 
 
@@ -93,6 +94,16 @@ struct ContentView: View {
 
 
 struct HUDView_Previews: PreviewProvider {
 struct HUDView_Previews: PreviewProvider {
     static var previews: some View {
     static var previews: some View {
-        ContentView()
+        snapshots.previews.previewLayout(.sizeThatFits)
+    }
+
+    static var snapshots: PreviewSnapshots<String> {
+        PreviewSnapshots(
+            configurations: [
+                .init(name: NCGlobal.shared.defaultSnapshotConfiguration, state: "")
+            ],
+            configure: { _ in
+                ContentView().frameForPreview()
+            })
     }
     }
 }
 }

+ 0 - 1
iOSClient/Groupfolders/NCGroupfolders.swift

@@ -34,7 +34,6 @@ class NCGroupfolders: NCCollectionViewCommon {
         titleCurrentFolder = NSLocalizedString("_group_folders_", comment: "")
         titleCurrentFolder = NSLocalizedString("_group_folders_", comment: "")
         layoutKey = NCGlobal.shared.layoutViewGroupfolders
         layoutKey = NCGlobal.shared.layoutViewGroupfolders
         enableSearchBar = false
         enableSearchBar = false
-        headerMenuButtonsCommand = false
         headerMenuButtonsView = true
         headerMenuButtonsView = true
         headerRichWorkspaceDisable = true
         headerRichWorkspaceDisable = true
         emptyImage = UIImage(named: "folder_group")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width)
         emptyImage = UIImage(named: "folder_group")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width)

+ 15 - 0
iOSClient/Images.xcassets/more-apps-template.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "more-apps.svg",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "template-rendering-intent" : "template"
+  }
+}

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
iOSClient/Images.xcassets/more-apps-template.imageset/more-apps.svg


+ 15 - 0
iOSClient/Images.xcassets/notes-template.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "notes.svg",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "template-rendering-intent" : "template"
+  }
+}

+ 1 - 0
iOSClient/Images.xcassets/notes-template.imageset/notes.svg

@@ -0,0 +1 @@
+<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="m0 0h24v24h-24z" fill="none"/><path d="m3 17.25v3.75h3.75l11.06-11.06-3.75-3.75zm17.71-10.21c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75z" fill="#fff"/></svg>

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

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

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


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


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


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

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

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


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


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


+ 15 - 0
iOSClient/Images.xcassets/talk-template.imageset/Contents.json

@@ -0,0 +1,15 @@
+{
+  "images" : [
+    {
+      "filename" : "talk.png",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  },
+  "properties" : {
+    "template-rendering-intent" : "template"
+  }
+}

BIN
iOSClient/Images.xcassets/talk-template.imageset/talk.png


+ 11 - 15
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -72,7 +72,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     internal var titleCurrentFolder = ""
     internal var titleCurrentFolder = ""
     internal var titlePreviusFolder: String?
     internal var titlePreviusFolder: String?
     internal var enableSearchBar: Bool = false
     internal var enableSearchBar: Bool = false
-    internal var headerMenuButtonsCommand: Bool = true
     internal var headerMenuButtonsView: Bool = true
     internal var headerMenuButtonsView: Bool = true
     internal var headerRichWorkspaceDisable:Bool = false
     internal var headerRichWorkspaceDisable:Bool = false
     internal var emptyImage: UIImage?
     internal var emptyImage: UIImage?
@@ -1304,7 +1303,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
             
             
             let imageIcon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
             let imageIcon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag))
 
 
-            if metadata.isImage || metadata.isMovie {
+            if !metadata.isDirectoryE2EE && (metadata.isImage || metadata.isMovie) {
                 var metadatas: [tableMetadata] = []
                 var metadatas: [tableMetadata] = []
                 for metadata in metadataSourceForAllSections {
                 for metadata in metadataSourceForAllSections {
                     if metadata.isImage || metadata.isMovie {
                     if metadata.isImage || metadata.isMovie {
@@ -1494,7 +1493,6 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 cell.fileInfoLabel?.text = NSLocalizedString("_in_", comment: "") + " " + NCUtilityFileSystem.shared.getPath(path: metadata.path, user: metadata.user)
                 cell.fileInfoLabel?.text = NSLocalizedString("_in_", comment: "") + " " + NCUtilityFileSystem.shared.getPath(path: metadata.path, user: metadata.user)
             } else {
             } else {
                 cell.fileInfoLabel?.text = metadata.subline
                 cell.fileInfoLabel?.text = metadata.subline
-                cell.titleInfoTrailingFull()
             }
             }
         } else {
         } else {
             cell.fileTitleLabel?.text = metadata.fileNameView
             cell.fileTitleLabel?.text = metadata.fileNameView
@@ -1668,6 +1666,13 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         // Add TAGS
         // Add TAGS
         cell.setTags(tags: Array(metadata.tags))
         cell.setTags(tags: Array(metadata.tags))
 
 
+        // Hide buttons
+        if metadata.name != NCGlobal.shared.appName {
+            cell.titleInfoTrailingFull()
+            cell.hideButtonShare(true)
+            cell.hideButtonMore(true)
+        }
+
         // ** IMPORT MUST BE AT THE END **
         // ** IMPORT MUST BE AT THE END **
         //
         //
 
 
@@ -1698,19 +1703,13 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 }
                 }
 
 
                 header.delegate = self
                 header.delegate = self
-                if headerMenuButtonsCommand && !isSearchingMode {
-                    let imageButton2 = isDirectoryE2EE ? UIImage(named: "folderEncrypted") : UIImage(named: "folder")
-                    let titleButton2 = isDirectoryE2EE ? NSLocalizedString("_create_folder_e2ee_", comment: "") : NSLocalizedString("_create_folder_", comment: "")
-                    header.setButtonsCommand(heigt: NCGlobal.shared.heightButtonsCommand, imageButton1: UIImage(named: "addImage"), titleButton1: NSLocalizedString("_upload_", comment: ""), imageButton2: imageButton2, titleButton2: titleButton2, imageButton3: UIImage(systemName: "doc.text.viewfinder"), titleButton3: NSLocalizedString("_scan_", comment: ""))
-                } else {
-                    header.setButtonsCommand(heigt: 0)
-                }
+
                 if headerMenuButtonsView {
                 if headerMenuButtonsView {
                     header.setStatusButtonsView(enable: !dataSource.getMetadataSourceForAllSections().isEmpty)
                     header.setStatusButtonsView(enable: !dataSource.getMetadataSourceForAllSections().isEmpty)
-                    header.setButtonsView(heigt: NCGlobal.shared.heightButtonsView)
+                    header.setButtonsView(height: NCGlobal.shared.heightButtonsView)
                     header.setSortedTitle(layoutForView?.titleButtonHeader ?? "")
                     header.setSortedTitle(layoutForView?.titleButtonHeader ?? "")
                 } else {
                 } else {
-                    header.setButtonsView(heigt: 0)
+                    header.setButtonsView(height: 0)
                 }
                 }
 
 
                 header.setRichWorkspaceHeight(heightHeaderRichWorkspace)
                 header.setRichWorkspaceHeight(heightHeaderRichWorkspace)
@@ -1785,9 +1784,6 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
 
 
         var size: CGFloat = 0
         var size: CGFloat = 0
 
 
-        if headerMenuButtonsCommand && !isSearchingMode {
-            size += NCGlobal.shared.heightButtonsCommand
-        }
         if headerMenuButtonsView {
         if headerMenuButtonsView {
             size += NCGlobal.shared.heightButtonsView
             size += NCGlobal.shared.heightButtonsView
         }
         }

+ 12 - 84
iOSClient/Main/Section Header Footer/NCSectionHeaderFooter.swift → iOSClient/Main/Section Header Footer/NCSectionHeaderMenu.swift

@@ -30,17 +30,11 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
     @IBOutlet weak var buttonOrder: UIButton!
     @IBOutlet weak var buttonOrder: UIButton!
     @IBOutlet weak var buttonMore: UIButton!
     @IBOutlet weak var buttonMore: UIButton!
 
 
-    @IBOutlet weak var button1: UIButton!
-    @IBOutlet weak var button2: UIButton!
-    @IBOutlet weak var button3: UIButton!
-
-    @IBOutlet weak var viewButtonsCommand: UIView!
     @IBOutlet weak var viewButtonsView: UIView!
     @IBOutlet weak var viewButtonsView: UIView!
     @IBOutlet weak var viewSeparator: UIView!
     @IBOutlet weak var viewSeparator: UIView!
     @IBOutlet weak var viewRichWorkspace: UIView!
     @IBOutlet weak var viewRichWorkspace: UIView!
     @IBOutlet weak var viewSection: UIView!
     @IBOutlet weak var viewSection: UIView!
 
 
-    @IBOutlet weak var viewButtonsCommandHeightConstraint: NSLayoutConstraint!
     @IBOutlet weak var viewButtonsViewHeightConstraint: NSLayoutConstraint!
     @IBOutlet weak var viewButtonsViewHeightConstraint: NSLayoutConstraint!
     @IBOutlet weak var viewSeparatorHeightConstraint: NSLayoutConstraint!
     @IBOutlet weak var viewSeparatorHeightConstraint: NSLayoutConstraint!
     @IBOutlet weak var viewRichWorkspaceHeightConstraint: NSLayoutConstraint!
     @IBOutlet weak var viewRichWorkspaceHeightConstraint: NSLayoutConstraint!
@@ -61,36 +55,12 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
 
 
         backgroundColor = .clear
         backgroundColor = .clear
 
 
-        buttonSwitch.setImage(UIImage(named: "switchList")!.image(color: .systemGray, size: 25), for: .normal)
+        buttonSwitch.setImage(UIImage(systemName: "list.bullet")!.image(color: .systemGray, size: 25), for: .normal)
 
 
         buttonOrder.setTitle("", for: .normal)
         buttonOrder.setTitle("", for: .normal)
         buttonOrder.setTitleColor(.systemBlue, for: .normal)
         buttonOrder.setTitleColor(.systemBlue, for: .normal)
         buttonMore.setImage(UIImage(named: "more")!.image(color: .systemGray, size: 25), for: .normal)
         buttonMore.setImage(UIImage(named: "more")!.image(color: .systemGray, size: 25), for: .normal)
 
 
-        button1.setImage(nil, for: .normal)
-        button1.isHidden = true
-        button1.backgroundColor = .clear
-        button1.setTitleColor(.systemBlue, for: .normal)
-        button1.layer.borderColor = UIColor.systemGray.cgColor
-        button1.layer.borderWidth = 0.4
-        button1.layer.cornerRadius = 3
-
-        button2.setImage(nil, for: .normal)
-        button2.isHidden = true
-        button2.backgroundColor = .clear
-        button2.setTitleColor(.systemBlue, for: .normal)
-        button2.layer.borderColor = UIColor.systemGray.cgColor
-        button2.layer.borderWidth = 0.4
-        button2.layer.cornerRadius = 3
-
-        button3.setImage(nil, for: .normal)
-        button3.isHidden = true
-        button3.backgroundColor = .clear
-        button3.setTitleColor(.systemBlue, for: .normal)
-        button3.layer.borderColor = UIColor.systemGray.cgColor
-        button3.layer.borderWidth = 0.4
-        button3.layer.cornerRadius = 3
-
         // Gradient
         // Gradient
         gradient.startPoint = CGPoint(x: 0, y: 0.50)
         gradient.startPoint = CGPoint(x: 0, y: 0.50)
         gradient.endPoint = CGPoint(x: 0, y: 1)
         gradient.endPoint = CGPoint(x: 0, y: 1)
@@ -127,47 +97,7 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         setInterfaceColor()
         setInterfaceColor()
     }
     }
 
 
-    //MARK: - Command
-
-    func setStatusButtonsCommand(enable: Bool) {
-
-        button1.isEnabled = enable
-        button2.isEnabled = enable
-        button3.isEnabled = enable
-    }
-
-    func setButtonsCommand(heigt :CGFloat, imageButton1: UIImage? = nil, titleButton1: String? = nil, imageButton2: UIImage? = nil, titleButton2: String? = nil, imageButton3: UIImage? = nil, titleButton3: String? = nil) {
-
-        viewButtonsCommandHeightConstraint.constant = heigt
-        if heigt == 0 {
-            viewButtonsView.isHidden = true
-            button1.isHidden = true
-            button2.isHidden = true
-            button3.isHidden = true
-        } else {
-            viewButtonsView.isHidden = false
-            if var image = imageButton1, let title = titleButton1 {
-                image = image.image(color: .systemGray, size: 25)
-                button1.setImage(image, for: .normal)
-                button1.isHidden = false
-                button1.setTitle(title.firstUppercased, for: .normal)
-            }
-            if var image = imageButton2, let title = titleButton2 {
-                image = image.image(color: .systemGray, size: 25)
-                button2.setImage(image, for: .normal)
-                button2.isHidden = false
-                button2.setTitle(title.firstUppercased, for: .normal)
-            }
-            if var image = imageButton3, let title = titleButton3 {
-                image = image.image(color: .systemGray, size: 25)
-                button3.setImage(image, for: .normal)
-                button3.isHidden = false
-                button3.setTitle(title.firstUppercased, for: .normal)
-            }
-        }
-    }
-
-    //MARK: - View
+    // MARK: - View
 
 
     func setStatusButtonsView(enable: Bool) {
     func setStatusButtonsView(enable: Bool) {
 
 
@@ -183,18 +113,18 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
 
 
     func setImageSwitchList() {
     func setImageSwitchList() {
 
 
-        buttonSwitch.setImage(UIImage(named: "switchList")!.image(color: .systemGray, size: 50), for: .normal)
+        buttonSwitch.setImage(UIImage(systemName: "list.bullet")!.image(color: .systemGray, width: 20, height: 15), for: .normal)
     }
     }
 
 
     func setImageSwitchGrid() {
     func setImageSwitchGrid() {
 
 
-        buttonSwitch.setImage(UIImage(named: "switchGrid")!.image(color: .systemGray, size: 50), for: .normal)
+        buttonSwitch.setImage(UIImage(systemName: "square.grid.2x2")!.image(color: .systemGray, size: 20), for: .normal)
     }
     }
 
 
-    func setButtonsView(heigt :CGFloat) {
+    func setButtonsView(height: CGFloat) {
 
 
-        viewButtonsViewHeightConstraint.constant = heigt
-        if heigt == 0 {
+        viewButtonsViewHeightConstraint.constant = height
+        if height == 0 {
             viewButtonsView.isHidden = true
             viewButtonsView.isHidden = true
         } else {
         } else {
             viewButtonsView.isHidden = false
             viewButtonsView.isHidden = false
@@ -204,12 +134,10 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
     func setSortedTitle(_ title: String) {
     func setSortedTitle(_ title: String) {
 
 
         let title = NSLocalizedString(title, comment: "")
         let title = NSLocalizedString(title, comment: "")
-        //let size = title.size(withAttributes: [.font: buttonOrder.titleLabel?.font as Any])
-
         buttonOrder.setTitle(title, for: .normal)
         buttonOrder.setTitle(title, for: .normal)
     }
     }
 
 
-    //MARK: - RichWorkspace
+    // MARK: - RichWorkspace
 
 
     func setRichWorkspaceHeight(_ size: CGFloat) {
     func setRichWorkspaceHeight(_ size: CGFloat) {
 
 
@@ -239,9 +167,9 @@ class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate
         }
         }
     }
     }
 
 
-    //MARK: - Section
+    // MARK: - Section
 
 
-    func setSectionHeight(_ size:CGFloat) {
+    func setSectionHeight(_ size: CGFloat) {
 
 
         viewSectionHeightConstraint.constant = size
         viewSectionHeightConstraint.constant = size
         if size == 0 {
         if size == 0 {
@@ -359,9 +287,9 @@ class NCSectionFooter: UICollectionReusableView, NCSectionFooterDelegate {
             filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + CCUtility.transformedSize(size)
             filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + CCUtility.transformedSize(size)
         }
         }
 
 
-        if foldersText == "" {
+        if foldersText.isEmpty {
             labelSection.text = filesText
             labelSection.text = filesText
-        } else if filesText == "" {
+        } else if filesText.isEmpty {
             labelSection.text = foldersText
             labelSection.text = foldersText
         } else {
         } else {
             labelSection.text = foldersText + ", " + filesText
             labelSection.text = foldersText + ", " + filesText

+ 28 - 86
iOSClient/Main/Section Header Footer/NCSectionHeaderMenu.xib

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait" appearance="light"/>
     <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
     <dependencies>
         <deployment identifier="iOS"/>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -15,55 +15,8 @@
             <rect key="frame" x="0.0" y="0.0" width="574" height="211"/>
             <rect key="frame" x="0.0" y="0.0" width="574" height="211"/>
             <autoresizingMask key="autoresizingMask"/>
             <autoresizingMask key="autoresizingMask"/>
             <subviews>
             <subviews>
-                <stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" alignment="bottom" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="5Lz-Ux-j8Z">
-                    <rect key="frame" x="10" y="0.0" width="554" height="50"/>
-                    <subviews>
-                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="tailTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Hie-dN-B9L">
-                            <rect key="frame" x="0.0" y="10" width="178" height="40"/>
-                            <constraints>
-                                <constraint firstAttribute="height" constant="40" id="luF-yL-wde"/>
-                            </constraints>
-                            <fontDescription key="fontDescription" type="system" pointSize="13"/>
-                            <inset key="contentEdgeInsets" minX="16" minY="0.0" maxX="8" maxY="0.0"/>
-                            <inset key="imageEdgeInsets" minX="-8" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
-                            <state key="normal" title="Button 1"/>
-                            <connections>
-                                <action selector="touchUpInsideButton1:" destination="tys-A2-nDX" eventType="touchUpInside" id="n7r-8n-gT3"/>
-                            </connections>
-                        </button>
-                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="tailTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cjh-je-E6h">
-                            <rect key="frame" x="188" y="10" width="178" height="40"/>
-                            <constraints>
-                                <constraint firstAttribute="height" constant="40" id="Qbm-WY-vBX"/>
-                            </constraints>
-                            <fontDescription key="fontDescription" type="system" pointSize="13"/>
-                            <inset key="contentEdgeInsets" minX="16" minY="0.0" maxX="8" maxY="0.0"/>
-                            <inset key="imageEdgeInsets" minX="-8" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
-                            <state key="normal" title="Button 2"/>
-                            <connections>
-                                <action selector="touchUpInsideButton2:" destination="tys-A2-nDX" eventType="touchUpInside" id="hek-Xq-Lh2"/>
-                            </connections>
-                        </button>
-                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="tailTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Zta-tv-COt">
-                            <rect key="frame" x="376" y="10" width="178" height="40"/>
-                            <constraints>
-                                <constraint firstAttribute="height" constant="40" id="DG7-Fz-W9H"/>
-                            </constraints>
-                            <fontDescription key="fontDescription" type="system" pointSize="13"/>
-                            <inset key="contentEdgeInsets" minX="16" minY="0.0" maxX="8" maxY="0.0"/>
-                            <inset key="imageEdgeInsets" minX="-8" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
-                            <state key="normal" title="Button 3"/>
-                            <connections>
-                                <action selector="touchUpInsideButton3:" destination="tys-A2-nDX" eventType="touchUpInside" id="Krk-cP-Iq5"/>
-                            </connections>
-                        </button>
-                    </subviews>
-                    <constraints>
-                        <constraint firstAttribute="height" constant="50" id="d8V-tN-fUz"/>
-                    </constraints>
-                </stackView>
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="s4I-Jo-yCE">
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="s4I-Jo-yCE">
-                    <rect key="frame" x="0.0" y="50" width="574" height="50"/>
+                    <rect key="frame" x="0.0" y="20" width="574" height="50"/>
                     <subviews>
                     <subviews>
                         <button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1LD-cd-zhc">
                         <button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1LD-cd-zhc">
                             <rect key="frame" x="10" y="12.5" width="25" height="25"/>
                             <rect key="frame" x="10" y="12.5" width="25" height="25"/>
@@ -71,7 +24,8 @@
                                 <constraint firstAttribute="width" constant="25" id="D76-X9-Tw9"/>
                                 <constraint firstAttribute="width" constant="25" id="D76-X9-Tw9"/>
                                 <constraint firstAttribute="height" constant="25" id="izT-Ru-XYG"/>
                                 <constraint firstAttribute="height" constant="25" id="izT-Ru-XYG"/>
                             </constraints>
                             </constraints>
-                            <state key="normal" image="switchList"/>
+                            <color key="tintColor" systemColor="systemGrayColor"/>
+                            <state key="normal" image="list.bullet" catalog="system"/>
                             <connections>
                             <connections>
                                 <action selector="touchUpInsideSwitch:" destination="tys-A2-nDX" eventType="touchUpInside" id="iT8-1j-fib"/>
                                 <action selector="touchUpInsideSwitch:" destination="tys-A2-nDX" eventType="touchUpInside" id="iT8-1j-fib"/>
                             </connections>
                             </connections>
@@ -79,9 +33,7 @@
                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0bo-yl-t5k">
                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0bo-yl-t5k">
                             <rect key="frame" x="45" y="11" width="163" height="28"/>
                             <rect key="frame" x="45" y="11" width="163" height="28"/>
                             <fontDescription key="fontDescription" type="system" pointSize="13"/>
                             <fontDescription key="fontDescription" type="system" pointSize="13"/>
-                            <state key="normal" title="Sort by name (from A to Z)">
-                                <color key="titleColor" systemColor="darkTextColor"/>
-                            </state>
+                            <state key="normal" title="Sort by name (from A to Z)"/>
                             <connections>
                             <connections>
                                 <action selector="touchUpInsideOrder:" destination="tys-A2-nDX" eventType="touchUpInside" id="oiL-3O-hMQ"/>
                                 <action selector="touchUpInsideOrder:" destination="tys-A2-nDX" eventType="touchUpInside" id="oiL-3O-hMQ"/>
                             </connections>
                             </connections>
@@ -109,13 +61,25 @@
                     </constraints>
                     </constraints>
                 </view>
                 </view>
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LZu-Te-clJ">
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LZu-Te-clJ">
-                    <rect key="frame" x="0.0" y="99" width="574" height="1"/>
+                    <rect key="frame" x="0.0" y="69" width="574" height="1"/>
                     <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     <color key="tintColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     <color key="tintColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     <constraints>
                     <constraints>
                         <constraint firstAttribute="height" constant="1" id="VuP-sT-hUI"/>
                         <constraint firstAttribute="height" constant="1" id="VuP-sT-hUI"/>
                     </constraints>
                     </constraints>
                 </view>
                 </view>
+                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="f9U-NY-4OS">
+                    <rect key="frame" x="0.0" y="191" width="574" height="20"/>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="20" id="ZcL-Wd-xhN"/>
+                    </constraints>
+                </view>
+                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mB5-5n-AL9">
+                    <rect key="frame" x="10" y="193" width="554" height="18"/>
+                    <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
+                    <nil key="textColor"/>
+                    <nil key="highlightedColor"/>
+                </label>
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NC1-5C-E5z" userLabel="View RichWorkspace">
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NC1-5C-E5z" userLabel="View RichWorkspace">
                     <rect key="frame" x="0.0" y="141" width="574" height="50"/>
                     <rect key="frame" x="0.0" y="141" width="574" height="50"/>
                     <subviews>
                     <subviews>
@@ -135,53 +99,31 @@
                         <constraint firstAttribute="bottom" secondItem="pYo-pF-MGv" secondAttribute="bottom" id="t4r-dA-VyW"/>
                         <constraint firstAttribute="bottom" secondItem="pYo-pF-MGv" secondAttribute="bottom" id="t4r-dA-VyW"/>
                     </constraints>
                     </constraints>
                 </view>
                 </view>
-                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="f9U-NY-4OS">
-                    <rect key="frame" x="0.0" y="191" width="574" height="20"/>
-                    <subviews>
-                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mB5-5n-AL9">
-                            <rect key="frame" x="10" y="2" width="554" height="18"/>
-                            <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
-                            <nil key="textColor"/>
-                            <nil key="highlightedColor"/>
-                        </label>
-                    </subviews>
-                    <constraints>
-                        <constraint firstAttribute="trailing" secondItem="mB5-5n-AL9" secondAttribute="trailing" constant="10" id="Cct-8N-ghQ"/>
-                        <constraint firstAttribute="height" constant="20" id="ZcL-Wd-xhN"/>
-                        <constraint firstItem="mB5-5n-AL9" firstAttribute="leading" secondItem="f9U-NY-4OS" secondAttribute="leading" constant="10" id="xQp-zk-G00"/>
-                        <constraint firstAttribute="bottom" secondItem="mB5-5n-AL9" secondAttribute="bottom" id="ySZ-Z1-BQ1"/>
-                    </constraints>
-                </view>
             </subviews>
             </subviews>
             <viewLayoutGuide key="safeArea" id="pm7-uW-mZE"/>
             <viewLayoutGuide key="safeArea" id="pm7-uW-mZE"/>
             <constraints>
             <constraints>
                 <constraint firstItem="f9U-NY-4OS" firstAttribute="leading" secondItem="pm7-uW-mZE" secondAttribute="leading" id="7kv-IL-kwZ"/>
                 <constraint firstItem="f9U-NY-4OS" firstAttribute="leading" secondItem="pm7-uW-mZE" secondAttribute="leading" id="7kv-IL-kwZ"/>
-                <constraint firstItem="s4I-Jo-yCE" firstAttribute="top" secondItem="5Lz-Ux-j8Z" secondAttribute="bottom" id="Bsp-bF-E1f"/>
                 <constraint firstItem="s4I-Jo-yCE" firstAttribute="leading" secondItem="pm7-uW-mZE" secondAttribute="leading" id="CaM-Eb-nHq"/>
                 <constraint firstItem="s4I-Jo-yCE" firstAttribute="leading" secondItem="pm7-uW-mZE" secondAttribute="leading" id="CaM-Eb-nHq"/>
                 <constraint firstItem="LZu-Te-clJ" firstAttribute="leading" secondItem="pm7-uW-mZE" secondAttribute="leading" id="CyS-jg-0vc"/>
                 <constraint firstItem="LZu-Te-clJ" firstAttribute="leading" secondItem="pm7-uW-mZE" secondAttribute="leading" id="CyS-jg-0vc"/>
+                <constraint firstAttribute="bottom" secondItem="mB5-5n-AL9" secondAttribute="bottom" id="EFG-nD-yUb"/>
                 <constraint firstItem="pm7-uW-mZE" firstAttribute="trailing" secondItem="f9U-NY-4OS" secondAttribute="trailing" id="GbG-un-mCe"/>
                 <constraint firstItem="pm7-uW-mZE" firstAttribute="trailing" secondItem="f9U-NY-4OS" secondAttribute="trailing" id="GbG-un-mCe"/>
-                <constraint firstItem="5Lz-Ux-j8Z" firstAttribute="leading" secondItem="pm7-uW-mZE" secondAttribute="leading" constant="10" id="Mlm-5i-CrU"/>
                 <constraint firstItem="pm7-uW-mZE" firstAttribute="trailing" secondItem="LZu-Te-clJ" secondAttribute="trailing" id="NiW-2m-3HS"/>
                 <constraint firstItem="pm7-uW-mZE" firstAttribute="trailing" secondItem="LZu-Te-clJ" secondAttribute="trailing" id="NiW-2m-3HS"/>
+                <constraint firstAttribute="trailing" secondItem="mB5-5n-AL9" secondAttribute="trailing" constant="10" id="OO6-Qd-6hP"/>
                 <constraint firstItem="NC1-5C-E5z" firstAttribute="leading" secondItem="pm7-uW-mZE" secondAttribute="leading" id="QpF-nE-s7J"/>
                 <constraint firstItem="NC1-5C-E5z" firstAttribute="leading" secondItem="pm7-uW-mZE" secondAttribute="leading" id="QpF-nE-s7J"/>
-                <constraint firstItem="pm7-uW-mZE" firstAttribute="trailing" secondItem="5Lz-Ux-j8Z" secondAttribute="trailing" constant="10" id="Rsh-4o-ndc"/>
                 <constraint firstItem="pm7-uW-mZE" firstAttribute="trailing" secondItem="NC1-5C-E5z" secondAttribute="trailing" id="UH6-8N-JUD"/>
                 <constraint firstItem="pm7-uW-mZE" firstAttribute="trailing" secondItem="NC1-5C-E5z" secondAttribute="trailing" id="UH6-8N-JUD"/>
+                <constraint firstItem="mB5-5n-AL9" firstAttribute="leading" secondItem="tys-A2-nDX" secondAttribute="leading" constant="10" id="bDt-8i-Gxr"/>
                 <constraint firstItem="LZu-Te-clJ" firstAttribute="top" secondItem="s4I-Jo-yCE" secondAttribute="bottom" constant="-1" id="ede-24-v8F"/>
                 <constraint firstItem="LZu-Te-clJ" firstAttribute="top" secondItem="s4I-Jo-yCE" secondAttribute="bottom" constant="-1" id="ede-24-v8F"/>
                 <constraint firstItem="pm7-uW-mZE" firstAttribute="bottom" secondItem="f9U-NY-4OS" secondAttribute="bottom" id="eyu-CE-rTX"/>
                 <constraint firstItem="pm7-uW-mZE" firstAttribute="bottom" secondItem="f9U-NY-4OS" secondAttribute="bottom" id="eyu-CE-rTX"/>
                 <constraint firstItem="pm7-uW-mZE" firstAttribute="trailing" secondItem="s4I-Jo-yCE" secondAttribute="trailing" id="oCg-UW-8TQ"/>
                 <constraint firstItem="pm7-uW-mZE" firstAttribute="trailing" secondItem="s4I-Jo-yCE" secondAttribute="trailing" id="oCg-UW-8TQ"/>
-                <constraint firstItem="5Lz-Ux-j8Z" firstAttribute="top" secondItem="pm7-uW-mZE" secondAttribute="top" id="os0-Gk-1V7"/>
                 <constraint firstItem="NC1-5C-E5z" firstAttribute="bottom" secondItem="f9U-NY-4OS" secondAttribute="top" id="pmY-5s-Pv2"/>
                 <constraint firstItem="NC1-5C-E5z" firstAttribute="bottom" secondItem="f9U-NY-4OS" secondAttribute="top" id="pmY-5s-Pv2"/>
+                <constraint firstItem="s4I-Jo-yCE" firstAttribute="top" secondItem="pm7-uW-mZE" secondAttribute="top" id="pzr-LC-JPk"/>
             </constraints>
             </constraints>
             <connections>
             <connections>
-                <outlet property="button1" destination="Hie-dN-B9L" id="kzL-vK-FCu"/>
-                <outlet property="button2" destination="cjh-je-E6h" id="jUf-rf-F2d"/>
-                <outlet property="button3" destination="Zta-tv-COt" id="jk9-MY-ylh"/>
                 <outlet property="buttonMore" destination="D0O-wK-14O" id="eEx-3R-zCS"/>
                 <outlet property="buttonMore" destination="D0O-wK-14O" id="eEx-3R-zCS"/>
                 <outlet property="buttonOrder" destination="0bo-yl-t5k" id="Kbw-BG-73C"/>
                 <outlet property="buttonOrder" destination="0bo-yl-t5k" id="Kbw-BG-73C"/>
                 <outlet property="buttonSwitch" destination="1LD-cd-zhc" id="Ec2-cM-CoY"/>
                 <outlet property="buttonSwitch" destination="1LD-cd-zhc" id="Ec2-cM-CoY"/>
                 <outlet property="labelSection" destination="mB5-5n-AL9" id="uxf-bN-nZA"/>
                 <outlet property="labelSection" destination="mB5-5n-AL9" id="uxf-bN-nZA"/>
                 <outlet property="textViewRichWorkspace" destination="pYo-pF-MGv" id="2h4-LP-T1z"/>
                 <outlet property="textViewRichWorkspace" destination="pYo-pF-MGv" id="2h4-LP-T1z"/>
-                <outlet property="viewButtonsCommand" destination="5Lz-Ux-j8Z" id="USK-Qe-J1d"/>
-                <outlet property="viewButtonsCommandHeightConstraint" destination="d8V-tN-fUz" id="sFt-OL-Fei"/>
                 <outlet property="viewButtonsView" destination="s4I-Jo-yCE" id="FOI-ZK-1oj"/>
                 <outlet property="viewButtonsView" destination="s4I-Jo-yCE" id="FOI-ZK-1oj"/>
                 <outlet property="viewButtonsViewHeightConstraint" destination="vvG-dH-6c1" id="SEQ-Tn-EE0"/>
                 <outlet property="viewButtonsViewHeightConstraint" destination="vvG-dH-6c1" id="SEQ-Tn-EE0"/>
                 <outlet property="viewRichWorkspace" destination="NC1-5C-E5z" id="NyN-tr-sJl"/>
                 <outlet property="viewRichWorkspace" destination="NC1-5C-E5z" id="NyN-tr-sJl"/>
@@ -195,13 +137,13 @@
         </collectionReusableView>
         </collectionReusableView>
     </objects>
     </objects>
     <resources>
     <resources>
+        <image name="list.bullet" catalog="system" width="128" height="87"/>
         <image name="moreBig" width="50" height="50"/>
         <image name="moreBig" width="50" height="50"/>
-        <image name="switchList" width="25" height="25"/>
-        <systemColor name="darkTextColor">
-            <color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-        </systemColor>
         <systemColor name="labelColor">
         <systemColor name="labelColor">
-            <color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+            <color red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
+        <systemColor name="systemGrayColor">
+            <color red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
         </systemColor>
         </systemColor>
     </resources>
     </resources>
 </document>
 </document>

+ 20 - 12
iOSClient/NCGlobal.swift

@@ -94,16 +94,16 @@ class NCGlobal: NSObject {
 
 
     // Nextcloud version
     // Nextcloud version
     //
     //
-    let nextcloudVersion12: Int                     =  12
-    let nextcloudVersion15: Int                     =  15
-    let nextcloudVersion17: Int                     =  17
-    let nextcloudVersion18: Int                     =  18
-    let nextcloudVersion20: Int                     =  20
-    let nextcloudVersion23: Int                     =  23
-    let nextcloudVersion24: Int                     =  24
-    let nextcloudVersion25: Int                     =  25
-    let nextcloudVersion26: Int                     =  26
-    let nextcloudVersion27: Int                     =  27
+    let nextcloudVersion12: Int                     = 12
+    let nextcloudVersion15: Int                     = 15
+    let nextcloudVersion17: Int                     = 17
+    let nextcloudVersion18: Int                     = 18
+    let nextcloudVersion20: Int                     = 20
+    let nextcloudVersion23: Int                     = 23
+    let nextcloudVersion24: Int                     = 24
+    let nextcloudVersion25: Int                     = 25
+    let nextcloudVersion26: Int                     = 26
+    let nextcloudVersion27: Int                     = 27
 
 
     // Nextcloud unsupported
     // Nextcloud unsupported
     //
     //
@@ -127,7 +127,6 @@ class NCGlobal: NSObject {
 
 
     // E2EE
     // E2EE
     //
     //
-    let e2eeMaxFileSize: UInt64                     = 500000000     // 500 MB
     let e2eePassphraseTest                          = "more over television factory tendency independence international intellectual impress interest sentence pony"
     let e2eePassphraseTest                          = "more over television factory tendency independence international intellectual impress interest sentence pony"
     @objc let e2eeReadVersions                      = ["1.1", "1.2"]
     @objc let e2eeReadVersions                      = ["1.1", "1.2"]
 
 
@@ -166,7 +165,6 @@ class NCGlobal: NSObject {
 
 
     // Standard height sections header/footer
     // Standard height sections header/footer
     //
     //
-    let heightButtonsCommand: CGFloat               = 50
     let heightButtonsView: CGFloat                  = 50
     let heightButtonsView: CGFloat                  = 50
     let heightSection: CGFloat                      = 30
     let heightSection: CGFloat                      = 30
     let heightFooter: CGFloat                       = 1
     let heightFooter: CGFloat                       = 1
@@ -441,4 +439,14 @@ class NCGlobal: NSObject {
     @objc var capabilityUserStatusEnabled: Bool                 = false
     @objc var capabilityUserStatusEnabled: Bool                 = false
     var capabilityExternalSites: Bool                           = false
     var capabilityExternalSites: Bool                           = false
     var capabilityGroupfoldersEnabled: Bool                     = false // NC27
     var capabilityGroupfoldersEnabled: Bool                     = false // NC27
+
+    // MORE APPS
+    let talkSchemeUrl                                           = "nextcloudtalk://"
+    let notesSchemeUrl                                          = "nextcloudnotes://"
+    let talkAppStoreUrl                                         = "https://apps.apple.com/de/app/nextcloud-talk/id1296825574"
+    let notesAppStoreUrl                                        = "https://apps.apple.com/de/app/nextcloud-notes/id813973264"
+    let moreAppsUrl                                             = "https://www.apple.com/us/search/nextcloud?src=globalnav"
+
+    // SNAPSHOT PREVIEW
+    let defaultSnapshotConfiguration                            = "DefaultPreviewConfiguration"
 }
 }

+ 277 - 36
iOSClient/Networking/E2EE/NCEndToEndEncryption.m

@@ -44,6 +44,8 @@
 #define fileNamePrivateKey          @"privateKey.pem"
 #define fileNamePrivateKey          @"privateKey.pem"
 #define fileNamePubliceKey          @"publicKey.pem"
 #define fileNamePubliceKey          @"publicKey.pem"
 
 
+#define streamBuffer                1024
+
 #define AES_KEY_128_LENGTH          16
 #define AES_KEY_128_LENGTH          16
 #define AES_KEY_256_LENGTH          32
 #define AES_KEY_256_LENGTH          32
 #define AES_IVEC_LENGTH             16
 #define AES_IVEC_LENGTH             16
@@ -536,7 +538,6 @@
 
 
 - (BOOL)encryptFile:(NSString *)fileName fileNameIdentifier:(NSString *)fileNameIdentifier directory:(NSString *)directory key:(NSString **)key initializationVector:(NSString **)initializationVector authenticationTag:(NSString **)authenticationTag
 - (BOOL)encryptFile:(NSString *)fileName fileNameIdentifier:(NSString *)fileNameIdentifier directory:(NSString *)directory key:(NSString **)key initializationVector:(NSString **)initializationVector authenticationTag:(NSString **)authenticationTag
 {
 {
-    NSMutableData *cipherData;
     NSData *authenticationTagData;
     NSData *authenticationTagData;
    
    
     NSData *plainData = [[NSFileManager defaultManager] contentsAtPath:[NSString stringWithFormat:@"%@/%@", directory, fileName]];
     NSData *plainData = [[NSFileManager defaultManager] contentsAtPath:[NSString stringWithFormat:@"%@/%@", directory, fileName]];
@@ -545,13 +546,11 @@
     
     
     NSData *keyData = [self generateKey:AES_KEY_128_LENGTH];
     NSData *keyData = [self generateKey:AES_KEY_128_LENGTH];
     NSData *initializationVectorData = [self generateIV:AES_IVEC_LENGTH];
     NSData *initializationVectorData = [self generateIV:AES_IVEC_LENGTH];
-    
-    BOOL result = [self encryptData:plainData cipher:&cipherData key:keyData keyLen:AES_KEY_128_LENGTH initializationVector:initializationVectorData authenticationTag:&authenticationTagData];
-    
-    if (cipherData != nil && result) {
-        
-        [cipherData writeToFile:[NSString stringWithFormat:@"%@/%@", directory, fileNameIdentifier] atomically:YES];
-        
+
+    BOOL result = [self encryptFile:[NSString stringWithFormat:@"%@/%@", directory, fileName] fileNameCipher:[NSString stringWithFormat:@"%@/%@", directory, fileNameIdentifier] key:keyData keyLen:AES_KEY_128_LENGTH initializationVector:initializationVectorData authenticationTag:&authenticationTagData];
+
+    if (result) {
+
         *key = [keyData base64EncodedStringWithOptions:0];
         *key = [keyData base64EncodedStringWithOptions:0];
         *initializationVector = [initializationVectorData base64EncodedStringWithOptions:0];
         *initializationVector = [initializationVectorData base64EncodedStringWithOptions:0];
         *authenticationTag = [authenticationTagData base64EncodedStringWithOptions:0];
         *authenticationTag = [authenticationTagData base64EncodedStringWithOptions:0];
@@ -568,23 +567,11 @@
 
 
 - (BOOL)decryptFile:(NSString *)fileName fileNameView:(NSString *)fileNameView ocId:(NSString *)ocId key:(NSString *)key initializationVector:(NSString *)initializationVector authenticationTag:(NSString *)authenticationTag
 - (BOOL)decryptFile:(NSString *)fileName fileNameView:(NSString *)fileNameView ocId:(NSString *)ocId key:(NSString *)key initializationVector:(NSString *)initializationVector authenticationTag:(NSString *)authenticationTag
 {
 {
-    NSMutableData *plainData;
-
-    NSData *cipherData = [[NSFileManager defaultManager] contentsAtPath:[CCUtility getDirectoryProviderStorageOcId:ocId fileNameView:fileName]];
-    if (cipherData == nil)
-        return false;
-    
     NSData *keyData = [[NSData alloc] initWithBase64EncodedString:key options:0];
     NSData *keyData = [[NSData alloc] initWithBase64EncodedString:key options:0];
     NSData *initializationVectorData = [[NSData alloc] initWithBase64EncodedString:initializationVector options:0];
     NSData *initializationVectorData = [[NSData alloc] initWithBase64EncodedString:initializationVector options:0];
     NSData *authenticationTagData = [[NSData alloc] initWithBase64EncodedString:authenticationTag options:0];
     NSData *authenticationTagData = [[NSData alloc] initWithBase64EncodedString:authenticationTag options:0];
 
 
-    BOOL result = [self decryptData:cipherData plain:&plainData key:keyData keyLen:AES_KEY_128_LENGTH initializationVector:initializationVectorData authenticationTag:authenticationTagData];
-    if (plainData != nil && result) {
-        [plainData writeToFile:[CCUtility getDirectoryProviderStorageOcId:ocId fileNameView:fileNameView] atomically:YES];
-        return true;
-    }
-    
-    return false;
+   return [self decryptFile:[CCUtility getDirectoryProviderStorageOcId:ocId fileNameView:fileName] fileNamePlain:[CCUtility getDirectoryProviderStorageOcId:ocId fileNameView:fileNameView] key:keyData keyLen:AES_KEY_128_LENGTH initializationVector:initializationVectorData authenticationTag:authenticationTagData];
 }
 }
 
 
 // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 // -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -729,7 +716,7 @@
 #pragma mark - AES/GCM/NoPadding
 #pragma mark - AES/GCM/NoPadding
 #
 #
 
 
-// Encryption using GCM mode
+// Encryption data using GCM mode
 - (BOOL)encryptData:(NSData *)plain cipher:(NSMutableData **)cipher key:(NSData *)key keyLen:(int)keyLen initializationVector:(NSData *)initializationVector authenticationTag:(NSData **)authenticationTag
 - (BOOL)encryptData:(NSData *)plain cipher:(NSMutableData **)cipher key:(NSData *)key keyLen:(int)keyLen initializationVector:(NSData *)initializationVector authenticationTag:(NSData **)authenticationTag
 {
 {
     int status = 0;
     int status = 0;
@@ -763,32 +750,41 @@
     else if (keyLen == AES_KEY_256_LENGTH)
     else if (keyLen == AES_KEY_256_LENGTH)
         status = EVP_EncryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, NULL, NULL);
         status = EVP_EncryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, NULL, NULL);
     
     
-    if (status <= 0)
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
         return NO;
         return NO;
+    }
     
     
     // Set IV length. Not necessary if this is 12 bytes (96 bits)
     // Set IV length. Not necessary if this is 12 bytes (96 bits)
     status = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, (int)sizeof(cIV), NULL);
     status = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, (int)sizeof(cIV), NULL);
-    if (status <= 0)
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
         return NO;
         return NO;
+    }
     
     
     // Initialise key and IV
     // Initialise key and IV
     status = EVP_EncryptInit_ex (ctx, NULL, NULL, cKey, cIV);
     status = EVP_EncryptInit_ex (ctx, NULL, NULL, cKey, cIV);
-    if (status <= 0)
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
         return NO;
         return NO;
+    }
     
     
     // Provide the message to be encrypted, and obtain the encrypted output
     // Provide the message to be encrypted, and obtain the encrypted output
     *cipher = [NSMutableData dataWithLength:[plain length]];
     *cipher = [NSMutableData dataWithLength:[plain length]];
     unsigned char * cCipher = [*cipher mutableBytes];
     unsigned char * cCipher = [*cipher mutableBytes];
     int cCipherLen = 0;
     int cCipherLen = 0;
     status = EVP_EncryptUpdate(ctx, cCipher, &cCipherLen, [plain bytes], (int)[plain length]);
     status = EVP_EncryptUpdate(ctx, cCipher, &cCipherLen, [plain bytes], (int)[plain length]);
-    if (status <= 0)
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
         return NO;
         return NO;
+    }
     
     
     // Finalise the encryption
     // Finalise the encryption
-    len = cCipherLen;
-    status = EVP_EncryptFinal_ex(ctx, cCipher+cCipherLen, &len);
-    if (status <= 0)
+    status = EVP_EncryptFinal_ex(ctx, cCipher, &cCipherLen);
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
         return NO;
         return NO;
+    }
     
     
     // Get the tag
     // Get the tag
     status = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, (int)sizeof(cTag), cTag);
     status = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, (int)sizeof(cTag), cTag);
@@ -797,13 +793,139 @@
     // Append TAG
     // Append TAG
     [*cipher appendData:*authenticationTag];
     [*cipher appendData:*authenticationTag];
 
 
-    // Free
     EVP_CIPHER_CTX_free(ctx);
     EVP_CIPHER_CTX_free(ctx);
     
     
     return status; // OpenSSL uses 1 for success
     return status; // OpenSSL uses 1 for success
 }
 }
 
 
-// Decryption using GCM mode
+// Encryption file using GCM mode
+- (BOOL)encryptFile:(NSString *)fileName fileNameCipher:(NSString *)fileNameCipher key:(NSData *)key keyLen:(int)keyLen initializationVector:(NSData *)initializationVector authenticationTag:(NSData **)authenticationTag
+{
+    int status = 0;
+    int len = 0;
+
+    // set up key
+    len = keyLen;
+    unsigned char cKey[len];
+    bzero(cKey, sizeof(cKey));
+    [key getBytes:cKey length:len];
+
+    // set up ivec
+    len = AES_IVEC_LENGTH;
+    unsigned char cIV[len];
+    bzero(cIV, sizeof(cIV));
+    [initializationVector getBytes:cIV length:len];
+
+    // set up tag
+    len = AES_GCM_TAG_LENGTH;
+    unsigned char cTag[len];
+    bzero(cTag, sizeof(cTag));
+
+    // Create and initialise the context
+    EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
+    if (!ctx) {
+        return NO;
+    }
+
+    // Initialise the encryption operation
+    if (keyLen == AES_KEY_128_LENGTH)
+        status = EVP_EncryptInit_ex(ctx, EVP_aes_128_gcm(), NULL, NULL, NULL);
+    else if (keyLen == AES_KEY_256_LENGTH)
+        status = EVP_EncryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, NULL, NULL);
+
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
+        return NO;
+    }
+
+    // Set IV length. Not necessary if this is 12 bytes (96 bits)
+    status = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, (int)sizeof(cIV), NULL);
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
+        return NO;
+    }
+
+    // Initialise key and IV
+    status = EVP_EncryptInit_ex (ctx, NULL, NULL, cKey, cIV);
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
+        return NO;
+    }
+
+    NSInputStream *inStream = [NSInputStream inputStreamWithFileAtPath:fileName];
+    [inStream open];
+    NSOutputStream *outStream = [NSOutputStream outputStreamToFileAtPath:fileNameCipher append:false];
+    [outStream open];
+
+    Byte buffer[streamBuffer];
+    NSInteger totalNumberOfBytesWritten = 0;
+
+    int cCipherLen = 0;
+    unsigned char *cCipher;
+
+    while ([inStream hasBytesAvailable]) {
+
+        NSInteger bytesRead = [inStream read:buffer maxLength:streamBuffer];
+
+        if (bytesRead > 0) {
+
+            cCipher = [[NSMutableData dataWithLength:bytesRead] mutableBytes];
+            status = EVP_EncryptUpdate(ctx, cCipher, &cCipherLen, [[NSData dataWithBytes:buffer length:bytesRead] bytes], (int)bytesRead);
+            if (status <= 0) {
+                [inStream close];
+                [outStream close];
+                EVP_CIPHER_CTX_free(ctx);
+                return NO;
+            }
+
+            if ([outStream hasSpaceAvailable]) {
+                totalNumberOfBytesWritten = [outStream write:cCipher maxLength:cCipherLen];
+                if (totalNumberOfBytesWritten != cCipherLen) {
+                    [inStream close];
+                    [outStream close];
+                    EVP_CIPHER_CTX_free(ctx);
+                    return NO;
+                }
+            }
+        }
+    }
+
+    [inStream close];
+
+    status = EVP_EncryptFinal_ex(ctx, cCipher, &cCipherLen);
+    if (status <= 0) {
+        [outStream close];
+        EVP_CIPHER_CTX_free(ctx);
+        return NO;
+    }
+
+    // Get the tag
+    status = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, (int)sizeof(cTag), cTag);
+    if (status <= 0) {
+        [outStream close];
+        EVP_CIPHER_CTX_free(ctx);
+        return NO;
+    }
+    *authenticationTag = [NSData dataWithBytes:cTag length:sizeof(cTag)];
+
+    // Append TAG
+    if ([outStream hasSpaceAvailable]) {
+        totalNumberOfBytesWritten = [outStream write:cTag maxLength:sizeof(cTag)];
+        if (totalNumberOfBytesWritten != sizeof(cTag)) {
+            status = NO;
+        }
+    } else {
+        status = NO;
+    }
+
+    [outStream close];
+
+    EVP_CIPHER_CTX_free(ctx);
+
+    return status; // OpenSSL uses 1 for success
+}
+
+// Decryption data using GCM mode
 - (BOOL)decryptData:(NSData *)cipher plain:(NSMutableData **)plain key:(NSData *)key keyLen:(int)keyLen initializationVector:(NSData *)initializationVector authenticationTag:(NSData *)authenticationTag
 - (BOOL)decryptData:(NSData *)cipher plain:(NSMutableData **)plain key:(NSData *)key keyLen:(int)keyLen initializationVector:(NSData *)initializationVector authenticationTag:(NSData *)authenticationTag
 {    
 {    
     int status = 0;
     int status = 0;
@@ -838,31 +960,41 @@
     else if (keyLen == AES_KEY_256_LENGTH)
     else if (keyLen == AES_KEY_256_LENGTH)
         status = EVP_DecryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, NULL, NULL);
         status = EVP_DecryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, NULL, NULL);
     
     
-    if (status <= 0)
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
         return NO;
         return NO;
+    }
     
     
     // Set IV length. Not necessary if this is 12 bytes (96 bits)
     // Set IV length. Not necessary if this is 12 bytes (96 bits)
     status = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, (int)sizeof(cIV), NULL);
     status = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, (int)sizeof(cIV), NULL);
-    if (status <= 0)
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
         return NO;
         return NO;
+    }
     
     
     // Initialise key and IV
     // Initialise key and IV
     status = EVP_DecryptInit_ex(ctx, NULL, NULL, cKey, cIV);
     status = EVP_DecryptInit_ex(ctx, NULL, NULL, cKey, cIV);
-    if (status <= 0)
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
         return NO;
         return NO;
+    }
     
     
     // Provide the message to be decrypted, and obtain the plaintext output
     // Provide the message to be decrypted, and obtain the plaintext output
     *plain = [NSMutableData dataWithLength:([cipher length])];
     *plain = [NSMutableData dataWithLength:([cipher length])];
     int cPlainLen = 0;
     int cPlainLen = 0;
     unsigned char * cPlain = [*plain mutableBytes];
     unsigned char * cPlain = [*plain mutableBytes];
     status = EVP_DecryptUpdate(ctx, cPlain, &cPlainLen, [cipher bytes], (int)([cipher length]));
     status = EVP_DecryptUpdate(ctx, cPlain, &cPlainLen, [cipher bytes], (int)([cipher length]));
-    if (status <= 0)
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
         return NO;
         return NO;
+    }
     
     
     // Tag is the last 16 bytes
     // Tag is the last 16 bytes
     status = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, (int)sizeof(cTag), cTag);
     status = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, (int)sizeof(cTag), cTag);
-    if (status <= 0)
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
         return NO;
         return NO;
+    }
     
     
     // Finalise the encryption
     // Finalise the encryption
     EVP_DecryptFinal_ex(ctx,NULL, &cPlainLen);
     EVP_DecryptFinal_ex(ctx,NULL, &cPlainLen);
@@ -873,6 +1005,115 @@
     return status; // OpenSSL uses 1 for success
     return status; // OpenSSL uses 1 for success
 }
 }
 
 
+// Decryption file using GCM mode
+- (BOOL)decryptFile:(NSString *)fileName fileNamePlain:(NSString *)fileNamePlain key:(NSData *)key keyLen:(int)keyLen initializationVector:(NSData *)initializationVector authenticationTag:(NSData *)authenticationTag
+{
+    int status = 0;
+    int len = 0;
+
+    // set up key
+    len = keyLen;
+    unsigned char cKey[len];
+    bzero(cKey, sizeof(cKey));
+    [key getBytes:cKey length:len];
+
+    // set up ivec
+    len = (int)[initializationVector length];
+    unsigned char cIV[len];
+    bzero(cIV, sizeof(cIV));
+    [initializationVector getBytes:cIV length:len];
+
+    // set up tag
+    len = (int)[authenticationTag length];;
+    unsigned char cTag[len];
+    bzero(cTag, sizeof(cTag));
+    [authenticationTag getBytes:cTag length:len];
+
+    // Create and initialise the context
+    EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
+    if (!ctx)
+        return NO;
+
+    // Initialise the decryption operation
+    if (keyLen == AES_KEY_128_LENGTH)
+        status = EVP_DecryptInit_ex(ctx, EVP_aes_128_gcm(), NULL, NULL, NULL);
+    else if (keyLen == AES_KEY_256_LENGTH)
+        status = EVP_DecryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, NULL, NULL);
+
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
+        return NO;
+    }
+
+    // Set IV length. Not necessary if this is 12 bytes (96 bits)
+    status = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, (int)sizeof(cIV), NULL);
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
+        return NO;
+    }
+
+    // Initialise key and IV
+    status = EVP_DecryptInit_ex(ctx, NULL, NULL, cKey, cIV);
+    if (status <= 0) {
+        EVP_CIPHER_CTX_free(ctx);
+        return NO;
+    }
+
+    NSInputStream *inStream = [NSInputStream inputStreamWithFileAtPath:fileName];
+    [inStream open];
+    NSOutputStream *outStream = [NSOutputStream outputStreamToFileAtPath:fileNamePlain append:false];
+    [outStream open];
+
+    Byte buffer[streamBuffer];
+    NSInteger totalNumberOfBytesWritten = 0;
+
+    int cPlainLen = 0;
+    unsigned char *cPlain;
+
+    while ([inStream hasBytesAvailable]) {
+
+        NSInteger bytesRead = [inStream read:buffer maxLength:streamBuffer];
+
+        if (bytesRead > 0) {
+
+            cPlain = [[NSMutableData dataWithLength:bytesRead] mutableBytes];
+            status = EVP_DecryptUpdate(ctx, cPlain, &cPlainLen, [[NSData dataWithBytes:buffer length:bytesRead] bytes], (int)bytesRead);
+            if (status <= 0) {
+                [inStream close];
+                [outStream close];
+                EVP_CIPHER_CTX_free(ctx);
+                return NO;
+            }
+
+            if ([outStream hasSpaceAvailable]) {
+                totalNumberOfBytesWritten = [outStream write:cPlain maxLength:cPlainLen];
+                if (totalNumberOfBytesWritten != cPlainLen) {
+                    [inStream close];
+                    [outStream close];
+                    EVP_CIPHER_CTX_free(ctx);
+                    return NO;
+                }
+            }
+        }
+    }
+
+    [inStream close];
+    [outStream close];
+
+    // Tag is the last 16 bytes
+    status = EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, (int)sizeof(cTag), cTag);
+    if (status <= 0)
+        return NO;
+
+    // Finalise the encryption
+    EVP_DecryptFinal_ex(ctx,NULL, &cPlainLen);
+
+    // Free
+    EVP_CIPHER_CTX_free(ctx);
+
+    return status; // OpenSSL uses 1 for success
+}
+
 #
 #
 #pragma mark - Utility
 #pragma mark - Utility
 #
 #

+ 0 - 7
iOSClient/Networking/E2EE/NCNetworkingE2EEUpload.swift

@@ -54,13 +54,6 @@ class NCNetworkingE2EEUpload: NSObject {
         let ocIdTemp = metadata.ocId
         let ocIdTemp = metadata.ocId
         let errorCreateEncrypted = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_e2e_error_create_encrypted_")
         let errorCreateEncrypted = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_e2e_error_create_encrypted_")
 
 
-        // Verify max size
-        if metadata.size > NCGlobal.shared.e2eeMaxFileSize {
-            NCManageDatabase.shared.deleteMetadata(predicate: NSPredicate(format: "ocId == %@", metadata.ocId))
-            NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterUploadedFile, userInfo: ["ocId": metadata.ocId, "serverUrl": metadata.serverUrl, "account": metadata.account, "fileName": metadata.fileName, "ocIdTemp": metadata.ocId, "error": NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "E2E Error file too big")])
-            return NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "E2E Error file too big")
-        }
-
         // Create metadata for upload
         // Create metadata for upload
         if let result = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "serverUrl == %@ AND fileNameView == %@ AND ocId != %@", metadata.serverUrl, metadata.fileNameView, metadata.ocId)) {
         if let result = NCManageDatabase.shared.getMetadata(predicate: NSPredicate(format: "serverUrl == %@ AND fileNameView == %@ AND ocId != %@", metadata.serverUrl, metadata.fileNameView, metadata.ocId)) {
             metadata.fileName = result.fileName
             metadata.fileName = result.fileName

+ 9 - 10
iOSClient/Networking/NCNetworking.swift

@@ -1188,18 +1188,18 @@ class NCNetworking: NSObject, NKCommonDelegate {
 
 
         if metadata.isDirectoryE2EE {
         if metadata.isDirectoryE2EE {
 #if !EXTENSION
 #if !EXTENSION
-            Task {
-                if let metadataLive = metadataLive {
-                    let error = await NCNetworkingE2EEDelete.shared.delete(metadata: metadataLive)
-                    if error == .success {
-                        return await NCNetworkingE2EEDelete.shared.delete(metadata: metadata)
-                    } else {
-                        return error
-                    }
-                } else {
+            if let metadataLive = metadataLive {
+                let error = await NCNetworkingE2EEDelete.shared.delete(metadata: metadataLive)
+                if error == .success {
                     return await NCNetworkingE2EEDelete.shared.delete(metadata: metadata)
                     return await NCNetworkingE2EEDelete.shared.delete(metadata: metadata)
+                } else {
+                    return error
                 }
                 }
+            } else {
+                return await NCNetworkingE2EEDelete.shared.delete(metadata: metadata)
             }
             }
+#else
+            return NKError()
 #endif
 #endif
         } else {
         } else {
             if let metadataLive = metadataLive {
             if let metadataLive = metadataLive {
@@ -1213,7 +1213,6 @@ class NCNetworking: NSObject, NKCommonDelegate {
                 return await deleteMetadataPlain(metadata)
                 return await deleteMetadataPlain(metadata)
             }
             }
         }
         }
-        return NKError()
     }
     }
 
 
     func deleteMetadataPlain(_ metadata: tableMetadata, customHeader: [String: String]? = nil) async -> (NKError) {
     func deleteMetadataPlain(_ metadata: tableMetadata, customHeader: [String: String]? = nil) async -> (NKError) {

+ 3 - 0
iOSClient/Notification/NCNotification.storyboard

@@ -159,6 +159,9 @@
                         </connections>
                         </connections>
                     </tableView>
                     </tableView>
                     <navigationItem key="navigationItem" id="bV4-Hy-bmE"/>
                     <navigationItem key="navigationItem" id="bV4-Hy-bmE"/>
+                    <refreshControl key="refreshControl" opaque="NO" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" id="JwZ-Sr-qEU">
+                        <autoresizingMask key="autoresizingMask"/>
+                    </refreshControl>
                 </tableViewController>
                 </tableViewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="I7i-N5-tEB" userLabel="First Responder" sceneMemberID="firstResponder"/>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="I7i-N5-tEB" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
             </objects>

+ 4 - 2
iOSClient/Notification/NCNotification.swift

@@ -34,7 +34,6 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
     var emptyDataSet: NCEmptyDataSet?
     var emptyDataSet: NCEmptyDataSet?
     var isReloadDataSourceNetworkInProgress: Bool = false
     var isReloadDataSourceNetworkInProgress: Bool = false
 
 
-
     // MARK: - View Life Cycle
     // MARK: - View Life Cycle
 
 
     override func viewDidLoad() {
     override func viewDidLoad() {
@@ -48,6 +47,8 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
         tableView.estimatedRowHeight = 50.0
         tableView.estimatedRowHeight = 50.0
         tableView.backgroundColor = .systemBackground
         tableView.backgroundColor = .systemBackground
 
 
+        refreshControl?.addTarget(self, action: #selector(getNetwokingNotification), for: .valueChanged)
+
         // Empty
         // Empty
         let offset = (self.navigationController?.navigationBar.bounds.height ?? 0) - 20
         let offset = (self.navigationController?.navigationBar.bounds.height ?? 0) - 20
         emptyDataSet = NCEmptyDataSet(view: tableView, offset: -offset, delegate: self)
         emptyDataSet = NCEmptyDataSet(view: tableView, offset: -offset, delegate: self)
@@ -294,7 +295,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
 
 
     // MARK: - Load notification networking
     // MARK: - Load notification networking
 
 
-    func getNetwokingNotification() {
+   @objc func getNetwokingNotification() {
 
 
         isReloadDataSourceNetworkInProgress = true
         isReloadDataSourceNetworkInProgress = true
         self.tableView.reloadData()
         self.tableView.reloadData()
@@ -309,6 +310,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
                     }
                     }
                     self.notifications.append(notification as! NKNotifications)
                     self.notifications.append(notification as! NKNotifications)
                 }
                 }
+                self.refreshControl?.endRefreshing()
                 self.isReloadDataSourceNetworkInProgress = false
                 self.isReloadDataSourceNetworkInProgress = false
                 self.tableView.reloadData()
                 self.tableView.reloadData()
             }
             }

+ 0 - 1
iOSClient/Offline/NCOffline.swift

@@ -34,7 +34,6 @@ class NCOffline: NCCollectionViewCommon {
         titleCurrentFolder = NSLocalizedString("_manage_file_offline_", comment: "")
         titleCurrentFolder = NSLocalizedString("_manage_file_offline_", comment: "")
         layoutKey = NCGlobal.shared.layoutViewOffline
         layoutKey = NCGlobal.shared.layoutViewOffline
         enableSearchBar = false
         enableSearchBar = false
-        headerMenuButtonsCommand = false
         headerMenuButtonsView = true
         headerMenuButtonsView = true
         headerRichWorkspaceDisable = true
         headerRichWorkspaceDisable = true
         emptyImage = UIImage(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width)
         emptyImage = UIImage(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width)

+ 0 - 1
iOSClient/Recent/NCRecent.swift

@@ -34,7 +34,6 @@ class NCRecent: NCCollectionViewCommon {
         titleCurrentFolder = NSLocalizedString("_recent_", comment: "")
         titleCurrentFolder = NSLocalizedString("_recent_", comment: "")
         layoutKey = NCGlobal.shared.layoutViewRecent
         layoutKey = NCGlobal.shared.layoutViewRecent
         enableSearchBar = false
         enableSearchBar = false
-        headerMenuButtonsCommand = false
         headerMenuButtonsView = false
         headerMenuButtonsView = false
         headerRichWorkspaceDisable = true
         headerRichWorkspaceDisable = true
         emptyImage = NCUtility.shared.loadImage(named: "clock.arrow.circlepath", color: .gray, size: UIScreen.main.bounds.width)
         emptyImage = NCUtility.shared.loadImage(named: "clock.arrow.circlepath", color: .gray, size: UIScreen.main.bounds.width)

+ 1 - 2
iOSClient/Select/NCSelect.swift

@@ -599,8 +599,7 @@ extension NCSelect: UICollectionViewDataSource {
 
 
                 header.delegate = self
                 header.delegate = self
 
 
-                header.setButtonsCommand(heigt: 0)
-                header.setButtonsView(heigt: NCGlobal.shared.heightButtonsView)
+                header.setButtonsView(height: NCGlobal.shared.heightButtonsView)
                 header.setStatusButtonsView(enable: !dataSource.getMetadataSourceForAllSections().isEmpty)
                 header.setStatusButtonsView(enable: !dataSource.getMetadataSourceForAllSections().isEmpty)
                 header.setSortedTitle(layoutForView?.titleButtonHeader ?? "")
                 header.setSortedTitle(layoutForView?.titleButtonHeader ?? "")
 
 

+ 0 - 1
iOSClient/Shares/NCShares.swift

@@ -34,7 +34,6 @@ class NCShares: NCCollectionViewCommon {
         titleCurrentFolder = NSLocalizedString("_list_shares_", comment: "")
         titleCurrentFolder = NSLocalizedString("_list_shares_", comment: "")
         layoutKey = NCGlobal.shared.layoutViewShares
         layoutKey = NCGlobal.shared.layoutViewShares
         enableSearchBar = false
         enableSearchBar = false
-        headerMenuButtonsCommand = false
         headerMenuButtonsView = true
         headerMenuButtonsView = true
         headerRichWorkspaceDisable = true
         headerRichWorkspaceDisable = true
         emptyImage = UIImage(named: "share")?.image(color: .gray, size: UIScreen.main.bounds.width)
         emptyImage = UIImage(named: "share")?.image(color: .gray, size: UIScreen.main.bounds.width)

BIN
iOSClient/Supporting Files/ar.lproj/InfoPlist.strings


BIN
iOSClient/Supporting Files/ar.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/cs-CZ.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/de.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/el.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/es.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/fr.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/gl.lproj/InfoPlist.strings


BIN
iOSClient/Supporting Files/gl.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/hu.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/ko.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/pt-BR.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/ru.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/sl.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/sr.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/sv.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/tr.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/uk.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/zh-Hans.lproj/Localizable.strings


BIN
iOSClient/Supporting Files/zh_HK.lproj/Localizable.strings


+ 0 - 1
iOSClient/Transfers/NCTransfers.swift

@@ -37,7 +37,6 @@ class NCTransfers: NCCollectionViewCommon, NCTransferCellDelegate {
         titleCurrentFolder = NSLocalizedString("_transfers_", comment: "")
         titleCurrentFolder = NSLocalizedString("_transfers_", comment: "")
         layoutKey = NCGlobal.shared.layoutViewTransfers
         layoutKey = NCGlobal.shared.layoutViewTransfers
         enableSearchBar = false
         enableSearchBar = false
-        headerMenuButtonsCommand = false
         headerMenuButtonsView = false
         headerMenuButtonsView = false
         headerRichWorkspaceDisable = true
         headerRichWorkspaceDisable = true
         emptyImage = NCUtility.shared.loadImage(named: "arrow.left.arrow.right", color: .gray, size: UIScreen.main.bounds.width)
         emptyImage = NCUtility.shared.loadImage(named: "arrow.left.arrow.right", color: .gray, size: UIScreen.main.bounds.width)

+ 2 - 11
iOSClient/Trash/NCTrash+CollectionView.swift

@@ -156,16 +156,7 @@ extension NCTrash: UICollectionViewDataSource {
             header.delegate = self
             header.delegate = self
             header.setStatusButtonsView(enable: !datasource.isEmpty)
             header.setStatusButtonsView(enable: !datasource.isEmpty)
             header.setSortedTitle(layoutForView?.titleButtonHeader ?? "")
             header.setSortedTitle(layoutForView?.titleButtonHeader ?? "")
-            if isEditMode {
-                header.setButtonsCommand(heigt: NCGlobal.shared.heightButtonsCommand,
-                                         imageButton1: UIImage(named: "restore"), titleButton1: NSLocalizedString("_trash_restore_selected_", comment: ""),
-                                         imageButton2: UIImage(named: "trash"), titleButton2: NSLocalizedString("_trash_delete_selected_", comment: ""))
-            } else {
-                header.setButtonsCommand(heigt: NCGlobal.shared.heightButtonsCommand,
-                                         imageButton1: UIImage(named: "restore"), titleButton1: NSLocalizedString("_trash_restore_all_", comment: ""),
-                                         imageButton2: UIImage(named: "trash"), titleButton2: NSLocalizedString("_trash_delete_all_", comment: ""))
-            }
-            header.setButtonsView(heigt: NCGlobal.shared.heightButtonsView)
+            header.setButtonsView(height: NCGlobal.shared.heightButtonsView)
             header.setRichWorkspaceHeight(0)
             header.setRichWorkspaceHeight(0)
             header.setSectionHeight(0)
             header.setSectionHeight(0)
 
 
@@ -188,7 +179,7 @@ extension NCTrash: UICollectionViewDataSource {
 extension NCTrash: UICollectionViewDelegateFlowLayout {
 extension NCTrash: UICollectionViewDelegateFlowLayout {
 
 
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
-        return CGSize(width: collectionView.frame.width, height: NCGlobal.shared.heightButtonsView + NCGlobal.shared.heightButtonsCommand)
+        return CGSize(width: collectionView.frame.width, height: NCGlobal.shared.heightButtonsView)
     }
     }
 
 
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {

+ 2 - 2
iOSClient/Trash/NCTrash.swift

@@ -72,12 +72,12 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
         gridLayout = NCGridLayout()
         gridLayout = NCGridLayout()
 
 
         // Add Refresh Control
         // Add Refresh Control
-        collectionView.addSubview(refreshControl)
+        collectionView.refreshControl = refreshControl
         refreshControl.tintColor = .gray
         refreshControl.tintColor = .gray
         refreshControl.addTarget(self, action: #selector(loadListingTrash), for: .valueChanged)
         refreshControl.addTarget(self, action: #selector(loadListingTrash), for: .valueChanged)
 
 
         // Empty
         // Empty
-        emptyDataSet = NCEmptyDataSet(view: collectionView, offset: NCGlobal.shared.heightButtonsView + NCGlobal.shared.heightButtonsCommand, delegate: self)
+        emptyDataSet = NCEmptyDataSet(view: collectionView, offset: NCGlobal.shared.heightButtonsView, delegate: self)
 
 
         NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSource), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadDataSource), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSource), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadDataSource), object: nil)
     }
     }

+ 1 - 0
iOSClient/Viewer/NCViewer.swift

@@ -100,6 +100,7 @@ class NCViewer: NSObject {
                     let viewController: NCViewerPDF = UIStoryboard(name: "NCViewerPDF", bundle: nil).instantiateInitialViewController() as! NCViewerPDF
                     let viewController: NCViewerPDF = UIStoryboard(name: "NCViewerPDF", bundle: nil).instantiateInitialViewController() as! NCViewerPDF
 
 
                     viewController.metadata = metadata
                     viewController.metadata = metadata
+                    viewController.titleView = metadata.fileNameView
                     viewController.imageIcon = imageIcon
                     viewController.imageIcon = imageIcon
 
 
                     navigationController.pushViewController(viewController, animated: true)
                     navigationController.pushViewController(viewController, animated: true)

+ 58 - 3
iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift

@@ -31,6 +31,7 @@ class NCPlayer: NSObject {
     internal let appDelegate = UIApplication.shared.delegate as! AppDelegate
     internal let appDelegate = UIApplication.shared.delegate as! AppDelegate
     internal var url: URL?
     internal var url: URL?
     internal var player = VLCMediaPlayer()
     internal var player = VLCMediaPlayer()
+    internal var dialogProvider: VLCDialogProvider?
     internal var metadata: tableMetadata
     internal var metadata: tableMetadata
     internal var singleTapGestureRecognizer: UITapGestureRecognizer?
     internal var singleTapGestureRecognizer: UITapGestureRecognizer?
     internal var activityIndicator: UIActivityIndicatorView
     internal var activityIndicator: UIActivityIndicatorView
@@ -90,6 +91,9 @@ class NCPlayer: NSObject {
         player.media = VLCMedia(url: url)
         player.media = VLCMedia(url: url)
         player.delegate = self
         player.delegate = self
 
 
+        dialogProvider = VLCDialogProvider(library: VLCLibrary.shared(), customUI: true)
+        dialogProvider?.customRenderer = self
+
         // player?.media?.addOption("--network-caching=500")
         // player?.media?.addOption("--network-caching=500")
         player.media?.addOption(":http-user-agent=\(userAgent)")
         player.media?.addOption(":http-user-agent=\(userAgent)")
 
 
@@ -260,9 +264,6 @@ extension NCPlayer: VLCMediaPlayerDelegate {
             print("Played mode: ENDED")
             print("Played mode: ENDED")
             break
             break
         case .error:
         case .error:
-            let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_error_something_wrong_")
-            NCContentPresenter.shared.showError(error: error, priority: .max)
-            playerToolBar?.removeFromSuperview()
             print("Played mode: ERROR")
             print("Played mode: ERROR")
             break
             break
         case .playing:
         case .playing:
@@ -340,3 +341,57 @@ extension NCPlayer: VLCMediaThumbnailerDelegate {
 
 
     func mediaThumbnailer(_ mediaThumbnailer: VLCMediaThumbnailer, didFinishThumbnail thumbnail: CGImage) { }
     func mediaThumbnailer(_ mediaThumbnailer: VLCMediaThumbnailer, didFinishThumbnail thumbnail: CGImage) { }
 }
 }
+
+extension NCPlayer: VLCCustomDialogRendererProtocol {
+
+    func showError(withTitle error: String, message: String) {
+
+        let alert = UIAlertController(title: error, message: message, preferredStyle: .alert)
+
+        alert.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in
+            self.playerToolBar?.removeFromSuperview()
+            self.viewerMediaPage?.viewUnload()
+        }))
+
+        self.viewerMediaPage?.present(alert, animated: true)
+    }
+
+    func showLogin(withTitle title: String, message: String, defaultUsername username: String?, askingForStorage: Bool, withReference reference: NSValue) {
+        // UIAlertController other states...
+    }
+
+    func showQuestion(withTitle title: String, message: String, type questionType: VLCDialogQuestionType, cancel cancelString: String?, action1String: String?, action2String: String?, withReference reference: NSValue) {
+
+        let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
+
+        if let action1String = action1String {
+            alert.addAction(UIAlertAction(title: action1String, style: .default, handler: { _ in
+                self.dialogProvider?.postAction(1, forDialogReference: reference)
+            }))
+        }
+        if let action2String = action2String {
+            alert.addAction(UIAlertAction(title: action2String, style: .default, handler: { _ in
+                self.dialogProvider?.postAction(2, forDialogReference: reference)
+            }))
+        }
+        if let cancelString = cancelString {
+            alert.addAction(UIAlertAction(title: cancelString, style: .cancel, handler: { _ in
+                self.dialogProvider?.postAction(3, forDialogReference: reference)
+            }))
+        }
+
+        self.viewerMediaPage?.present(alert, animated: true)
+    }
+
+    func showProgress(withTitle title: String, message: String, isIndeterminate: Bool, position: Float, cancel cancelString: String?, withReference reference: NSValue) {
+        // UIAlertController other states...
+    }
+
+    func updateProgress(withReference reference: NSValue, message: String?, position: Float) {
+        // UIAlertController other states...
+    }
+
+    func cancelDialog(withReference reference: NSValue) {
+        // UIAlertController other states...
+    }
+}

+ 1 - 1
iOSClient/Viewer/NCViewerNextcloudText/NCViewerNextcloudText.swift

@@ -67,7 +67,7 @@ class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMes
         webView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 0).isActive = true
         webView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 0).isActive = true
         webView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: 0).isActive = true
         webView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: 0).isActive = true
         webView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 0).isActive = true
         webView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 0).isActive = true
-        bottomConstraint = webView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: 0)
+        bottomConstraint = webView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: 70)
         bottomConstraint?.isActive = true
         bottomConstraint?.isActive = true
 
 
         var request = URLRequest(url: URL(string: link)!)
         var request = URLRequest(url: URL(string: link)!)

+ 35 - 14
iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

@@ -30,7 +30,9 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
 
     @IBOutlet weak var pdfContainer: UIView!
     @IBOutlet weak var pdfContainer: UIView!
 
 
-    var metadata = tableMetadata()
+    var metadata: tableMetadata?
+    var url: URL?
+    var titleView: String?
     var imageIcon: UIImage?
     var imageIcon: UIImage?
 
 
     private var filePath = ""
     private var filePath = ""
@@ -65,14 +67,18 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
 
     override func viewDidLoad() {
     override func viewDidLoad() {
 
 
-        filePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
-        pdfDocument = PDFDocument(url: URL(fileURLWithPath: filePath))
+        if let url = self.url {
+            pdfDocument = PDFDocument(url: url)
+        } else if let metadata = self.metadata {
+            filePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
+            pdfDocument = PDFDocument(url: URL(fileURLWithPath: filePath))
+            navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "more")!.image(color: .label, size: 25), style: .plain, target: self, action: #selector(self.openMenuMore))
+        }
         defaultBackgroundColor = pdfView.backgroundColor
         defaultBackgroundColor = pdfView.backgroundColor
         view.backgroundColor = defaultBackgroundColor
         view.backgroundColor = defaultBackgroundColor
 
 
         navigationController?.navigationBar.prefersLargeTitles = false
         navigationController?.navigationBar.prefersLargeTitles = false
-        navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "more")!.image(color: .label, size: 25), style: .plain, target: self, action: #selector(self.openMenuMore))
-        navigationItem.title = metadata.fileNameView
+        navigationItem.title = titleView
 
 
         // TIP
         // TIP
 
 
@@ -123,6 +129,11 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
             pdfView.bottomAnchor.constraint(equalTo: pdfContainer.bottomAnchor)
             pdfView.bottomAnchor.constraint(equalTo: pdfContainer.bottomAnchor)
         ])
         ])
 
 
+        // MODAL
+        if self.navigationController?.presentingViewController != nil {
+            self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_close_", comment: ""), style: .plain, target: self, action: #selector(viewDismiss))
+        }
+
         // NOTIFIFICATION
         // NOTIFIFICATION
 
 
         NotificationCenter.default.addObserver(self, selector: #selector(favoriteFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterFavoriteFile), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(favoriteFile(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterFavoriteFile), object: nil)
@@ -281,6 +292,10 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
         navigationController?.popViewController(animated: true)
         navigationController?.popViewController(animated: true)
     }
     }
 
 
+    @objc func viewDismiss() {
+        self.dismiss(animated: true)
+    }
+
     // MARK: - Tip
     // MARK: - Tip
 
 
     func showTip() {
     func showTip() {
@@ -298,9 +313,9 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
 
         guard let userInfo = notification.userInfo as NSDictionary?,
         guard let userInfo = notification.userInfo as NSDictionary?,
               let serverUrl = userInfo["serverUrl"] as? String,
               let serverUrl = userInfo["serverUrl"] as? String,
-              serverUrl == self.metadata.serverUrl,
+              serverUrl == self.metadata?.serverUrl,
               let fileName = userInfo["fileName"] as? String,
               let fileName = userInfo["fileName"] as? String,
-              fileName == self.metadata.fileName
+              fileName == self.metadata?.fileName
         else { return }
         else { return }
 
 
         NCActivityIndicator.shared.start()
         NCActivityIndicator.shared.start()
@@ -310,9 +325,9 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
 
         guard let userInfo = notification.userInfo as NSDictionary?,
         guard let userInfo = notification.userInfo as NSDictionary?,
               let serverUrl = userInfo["serverUrl"] as? String,
               let serverUrl = userInfo["serverUrl"] as? String,
-              serverUrl == self.metadata.serverUrl,
+              serverUrl == self.metadata?.serverUrl,
               let fileName = userInfo["fileName"] as? String,
               let fileName = userInfo["fileName"] as? String,
-              fileName == self.metadata.fileName,
+              fileName == self.metadata?.fileName,
               let error = userInfo["error"] as? NKError
               let error = userInfo["error"] as? NKError
         else {
         else {
             return
             return
@@ -331,7 +346,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
 
         guard let userInfo = notification.userInfo as NSDictionary?,
         guard let userInfo = notification.userInfo as NSDictionary?,
               let ocId = userInfo["ocId"] as? String,
               let ocId = userInfo["ocId"] as? String,
-              ocId == self.metadata.ocId,
+              ocId == self.metadata?.ocId,
               let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId)
               let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId)
         else { return }
         else { return }
 
 
@@ -342,7 +357,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
 
         guard let userInfo = notification.userInfo as NSDictionary?,
         guard let userInfo = notification.userInfo as NSDictionary?,
               let ocId = userInfo["ocId"] as? String,
               let ocId = userInfo["ocId"] as? String,
-              ocId == self.metadata.ocId,
+              ocId == self.metadata?.ocId,
               let ocIdNew = userInfo["ocIdNew"] as? String,
               let ocIdNew = userInfo["ocIdNew"] as? String,
               let metadataNew = NCManageDatabase.shared.getMetadataFromOcId(ocIdNew)
               let metadataNew = NCManageDatabase.shared.getMetadataFromOcId(ocIdNew)
         else { return }
         else { return }
@@ -357,7 +372,9 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
               let error = userInfo["error"] as? NKError
               let error = userInfo["error"] as? NKError
         else { return }
         else { return }
 
 
-        if error == .success, let ocId = ocId.first, metadata.ocId == ocId {
+        if error == .success,
+           let ocId = ocId.first,
+           metadata?.ocId == ocId {
             viewUnload()
             viewUnload()
         }
         }
     }
     }
@@ -366,7 +383,7 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
 
         guard let userInfo = notification.userInfo as NSDictionary?,
         guard let userInfo = notification.userInfo as NSDictionary?,
               let ocId = userInfo["ocId"] as? String,
               let ocId = userInfo["ocId"] as? String,
-              ocId == self.metadata.ocId,
+              ocId == self.metadata?.ocId,
               let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId)
               let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId)
         else { return }
         else { return }
 
 
@@ -410,7 +427,11 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
 
     @objc func openMenuMore() {
     @objc func openMenuMore() {
 
 
-        if imageIcon == nil { imageIcon = UIImage(named: "file_pdf") }
+        guard let metadata = self.metadata else { return }
+        if imageIcon == nil {
+            imageIcon = UIImage(named: "file_pdf")
+        }
+
         NCViewer.shared.toggleMenu(viewController: self, metadata: metadata, webView: false, imageIcon: imageIcon)
         NCViewer.shared.toggleMenu(viewController: self, metadata: metadata, webView: false, imageIcon: imageIcon)
     }
     }
 
 

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است