Skip to content

Commit 5821533

Browse files
NMC 1933 - Collabora customisation changes
1 parent 7a4bb44 commit 5821533

File tree

9 files changed

+1142
-5
lines changed

9 files changed

+1142
-5
lines changed
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
//
2+
// CollaboraTestCase.swift
3+
// NextcloudTests
4+
//
5+
// Created by A200073704 on 06/05/23.
6+
// Copyright © 2023 Marino Faggiana. All rights reserved.
7+
//
8+
9+
@testable import Nextcloud
10+
import XCTest
11+
import NextcloudKit
12+
13+
class CollaboraTestCase: XCTestCase {
14+
15+
16+
override func setUpWithError() throws {
17+
// Put setup code here. This method is called before the invocation of each test method in the class.
18+
}
19+
20+
override func tearDownWithError() throws {
21+
// Put teardown code here. This method is called after the invocation of each test method in the class.
22+
}
23+
24+
func testCollaboraDocumentIsPresent() {
25+
26+
var viewForDocument: NCMenuAction?
27+
28+
if let image = UIImage(named: "create_file_document") {
29+
viewForDocument = NCMenuAction(title: NSLocalizedString("_create_new_document_", comment: ""), icon: image, action: { _ in
30+
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() as? UINavigationController else {
31+
return
32+
}
33+
34+
let viewController = navigationController.topViewController as? NCCreateFormUploadDocuments
35+
viewController?.titleForm = NSLocalizedString("_create_new_document_", comment: "")
36+
})
37+
}
38+
39+
XCTAssertNotNil(viewForDocument)
40+
41+
}
42+
43+
func testCollaboraPresentationIsPresent() {
44+
45+
var viewForPresentation: NCMenuAction?
46+
47+
if let image = UIImage(named: "create_file_ppt") {
48+
viewForPresentation = NCMenuAction(title: NSLocalizedString("_create_new_presentation_", comment: ""), icon: image, action: { _ in
49+
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() as? UINavigationController else {
50+
return
51+
}
52+
53+
let viewController = navigationController.topViewController as? NCCreateFormUploadDocuments
54+
viewController?.titleForm = NSLocalizedString("_create_new_presentation_", comment: "")
55+
})
56+
}
57+
58+
XCTAssertNotNil(viewForPresentation)
59+
60+
}
61+
62+
func testCollaboraSpreadsheetIsPresent() {
63+
64+
var viewForSpreadsheet: NCMenuAction?
65+
66+
if let image = UIImage(named: "create_file_xls") {
67+
viewForSpreadsheet = NCMenuAction(title: NSLocalizedString("_create_new_spreadsheet_", comment: ""), icon: image, action: { _ in
68+
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() as? UINavigationController else {
69+
return
70+
}
71+
72+
let viewController = navigationController.topViewController as? NCCreateFormUploadDocuments
73+
viewController?.titleForm = NSLocalizedString("_create_new_spreadsheet_", comment: "")
74+
})
75+
}
76+
77+
XCTAssertNotNil(viewForSpreadsheet)
78+
79+
}
80+
81+
func testTextDocumentIsPresent() {
82+
83+
var textMenu: NCMenuAction?
84+
85+
if let image = UIImage(named: "file_txt_menu") {
86+
textMenu = NCMenuAction(title: NSLocalizedString("_create_nextcloudtext_document_", comment: ""), icon: image, action: { _ in
87+
guard let navigationController = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil).instantiateInitialViewController() as? UINavigationController else {
88+
return
89+
}
90+
91+
let viewController = navigationController.topViewController as? NCCreateFormUploadDocuments
92+
viewController?.titleForm = NSLocalizedString("_create_nextcloudtext_document_", comment: "")
93+
})
94+
}
95+
96+
XCTAssertNotNil(textMenu)
97+
98+
}
99+
100+
func testTextDocumentAction() {
101+
102+
let text = NCGlobal.shared.actionTextDocument
103+
XCTAssertNotNil(text, "Text Editor Should be opened")
104+
}
105+
106+
func testTextFieldIsPresent() {
107+
108+
let storyboard = UIStoryboard(name: "NCCreateFormUploadDocuments", bundle: nil)
109+
guard let viewController = storyboard.instantiateInitialViewController() as? NCCreateFormUploadDocuments else {
110+
return
111+
}
112+
113+
// Verify that a text field is present in the view controller
114+
let textFields = viewController.view.subviews.filter { $0 is UITextField }
115+
XCTAssertFalse(textFields.isEmpty, "No text field found in NCCreateFormUploadDocuments")
116+
}
117+
118+
func testSavePathFolder() {
119+
120+
let viewController = NCCreateFormUploadDocuments()
121+
122+
let form : XLFormDescriptor = XLFormDescriptor() as XLFormDescriptor
123+
form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow
124+
125+
var row : XLFormRowDescriptor
126+
127+
// the section with the title "Folder Destination"
128+
129+
row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: "kNMCFolderCustomCellType", title: "")
130+
row.action.formSelector = #selector(viewController.changeDestinationFolder(_:))
131+
132+
// Verify that section was found
133+
XCTAssertNotNil(row, "Expected save path section to exist in form.")
134+
135+
}
136+
137+
138+
139+
140+
141+
142+
}

iOSClient/BrowserWeb/NCBrowserWeb.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class NCBrowserWeb: UIViewController {
5555
buttonExit.isHidden = true
5656
} else {
5757
self.view.bringSubviewToFront(buttonExit)
58-
let image = NCUtility().loadImage(named: "xmark", colors: [.systemBlue])
58+
let image = NCUtility().loadImage(named: "xmark", colors: [NCBrandColor.shared.customer])
5959
buttonExit.setImage(image, for: .normal)
6060
}
6161

iOSClient/Data/NCManageDatabase+Metadata.swift

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,7 @@ extension tableMetadata {
324324

325325
// Return if is sharable
326326
func isSharable() -> Bool {
327-
if !NCGlobal.shared.capabilityFileSharingApiEnabled || (NCGlobal.shared.capabilityE2EEEnabled && isDirectoryE2EE) {
328-
return false
329-
}
327+
guard NCGlobal.shared.capabilityE2EEEnabled, !isDirectoryE2EE, !e2eEncrypted else { return false }
330328
return true
331329
}
332330
}
@@ -356,7 +354,14 @@ extension NCManageDatabase {
356354
metadata.fileNameView = file.fileName
357355
metadata.hasPreview = file.hasPreview
358356
metadata.hidden = file.hidden
359-
metadata.iconName = file.iconName
357+
switch (file.fileName as NSString).pathExtension {
358+
case "odg":
359+
metadata.iconName = "diagram"
360+
case "csv", "xlsm" :
361+
metadata.iconName = "file_xls"
362+
default:
363+
metadata.iconName = file.iconName
364+
}
360365
metadata.mountType = file.mountType
361366
metadata.name = file.name
362367
metadata.note = file.note
@@ -1172,4 +1177,32 @@ extension NCManageDatabase {
11721177
}
11731178
return nil
11741179
}
1180+
1181+
func getMediaMetadatas(predicate: NSPredicate, sorted: String? = nil, ascending: Bool = false) -> ThreadSafeArray<tableMetadata>? {
1182+
1183+
do {
1184+
let realm = try Realm()
1185+
if let sorted {
1186+
var results: [tableMetadata] = []
1187+
switch NCKeychain().mediaSortDate {
1188+
case "date":
1189+
results = realm.objects(tableMetadata.self).filter(predicate).sorted { ($0.date as Date) > ($1.date as Date) }
1190+
case "creationDate":
1191+
results = realm.objects(tableMetadata.self).filter(predicate).sorted { ($0.creationDate as Date) > ($1.creationDate as Date) }
1192+
case "uploadDate":
1193+
results = realm.objects(tableMetadata.self).filter(predicate).sorted { ($0.uploadDate as Date) > ($1.uploadDate as Date) }
1194+
default:
1195+
let results = realm.objects(tableMetadata.self).filter(predicate)
1196+
return ThreadSafeArray(results.map { tableMetadata.init(value: $0) })
1197+
}
1198+
return ThreadSafeArray(results.map { tableMetadata.init(value: $0) })
1199+
} else {
1200+
let results = realm.objects(tableMetadata.self).filter(predicate)
1201+
return ThreadSafeArray(results.map { tableMetadata.init(value: $0) })
1202+
}
1203+
} catch let error as NSError {
1204+
NextcloudKit.shared.nkCommonInstance.writeLog("Could not access database: \(error)")
1205+
}
1206+
return nil
1207+
}
11751208
}

0 commit comments

Comments
 (0)