Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements varie #2983

Merged
merged 17 commits into from
Jul 17, 2024
2 changes: 1 addition & 1 deletion Brand/Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ import Foundation
// Database Realm
//
let databaseName = "nextcloud.realm"
let databaseSchemaVersion: UInt64 = 349
let databaseSchemaVersion: UInt64 = 350
12 changes: 12 additions & 0 deletions Nextcloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,9 @@
F7BB7E4727A18C56009B9F29 /* Parchment in Frameworks */ = {isa = PBXBuildFile; productRef = F7BB7E4627A18C56009B9F29 /* Parchment */; };
F7BC287E26663F6C004D46C5 /* NCViewCertificateDetails.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7BC287D26663F6C004D46C5 /* NCViewCertificateDetails.storyboard */; };
F7BC288026663F85004D46C5 /* NCViewCertificateDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BC287F26663F85004D46C5 /* NCViewCertificateDetails.swift */; };
F7BD0A002C468925003A4A6D /* NCMedia+CollectionViewDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BD09FF2C468925003A4A6D /* NCMedia+CollectionViewDataSource.swift */; };
F7BD0A022C4689A4003A4A6D /* NCMedia+CollectionViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BD0A012C4689A4003A4A6D /* NCMedia+CollectionViewDelegate.swift */; };
F7BD0A042C4689E9003A4A6D /* NCMedia+MediaLayoutDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BD0A032C4689E9003A4A6D /* NCMedia+MediaLayoutDelegate.swift */; };
F7BD71E62636EAFC00643C34 /* NCNetworkingE2EE.swift in Sources */ = {isa = PBXBuildFile; fileRef = F785EE9C246196DF00B3F945 /* NCNetworkingE2EE.swift */; };
F7BF9D822934CA21009EE9A6 /* NCManageDatabase+LayoutForView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BF9D812934CA21009EE9A6 /* NCManageDatabase+LayoutForView.swift */; };
F7BF9D832934CA21009EE9A6 /* NCManageDatabase+LayoutForView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BF9D812934CA21009EE9A6 /* NCManageDatabase+LayoutForView.swift */; };
Expand Down Expand Up @@ -1564,6 +1567,9 @@
F7BB04851FD58ACB00BBFD2A /* cs-CZ */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "cs-CZ"; path = "cs-CZ.lproj/Localizable.strings"; sourceTree = "<group>"; };
F7BC287D26663F6C004D46C5 /* NCViewCertificateDetails.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCViewCertificateDetails.storyboard; sourceTree = "<group>"; };
F7BC287F26663F85004D46C5 /* NCViewCertificateDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewCertificateDetails.swift; sourceTree = "<group>"; };
F7BD09FF2C468925003A4A6D /* NCMedia+CollectionViewDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCMedia+CollectionViewDataSource.swift"; sourceTree = "<group>"; };
F7BD0A012C4689A4003A4A6D /* NCMedia+CollectionViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCMedia+CollectionViewDelegate.swift"; sourceTree = "<group>"; };
F7BD0A032C4689E9003A4A6D /* NCMedia+MediaLayoutDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCMedia+MediaLayoutDelegate.swift"; sourceTree = "<group>"; };
F7BE7C25290AC8C9002ABB61 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Intent.strings; sourceTree = "<group>"; };
F7BE7C27290ADEFD002ABB61 /* eu */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = eu; path = eu.lproj/Intent.strings; sourceTree = "<group>"; };
F7BE7C29290ADEFD002ABB61 /* ca */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ca; path = ca.lproj/Intent.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2848,8 +2854,11 @@
F720B5B72507B9A5008C94E5 /* Cell */,
F7501C302212E57400FB1415 /* NCMedia.storyboard */,
F7501C312212E57400FB1415 /* NCMedia.swift */,
F7BD09FF2C468925003A4A6D /* NCMedia+CollectionViewDataSource.swift */,
F7BD0A012C4689A4003A4A6D /* NCMedia+CollectionViewDelegate.swift */,
F72408322B8A27C900F128E2 /* NCMedia+Command.swift */,
F7802B312BD5584F00D74270 /* NCMedia+DragDrop.swift */,
F7BD0A032C4689E9003A4A6D /* NCMedia+MediaLayoutDelegate.swift */,
F78B87E62B62527100C65ADC /* NCMediaDataSource.swift */,
F78B87E82B62550800C65ADC /* NCMediaDownloadThumbnaill.swift */,
F755CB3F2B8CB13C00CE27E9 /* NCMediaLayout.swift */,
Expand Down Expand Up @@ -4213,6 +4222,7 @@
F790110E21415BF600D7B136 /* NCViewerRichDocument.swift in Sources */,
F78ACD4021903CC20088454D /* NCGridCell.swift in Sources */,
F7D890752BD25C570050B8A6 /* NCCollectionViewCommon+DragDrop.swift in Sources */,
F7BD0A042C4689E9003A4A6D /* NCMedia+MediaLayoutDelegate.swift in Sources */,
F761856B29E98543006EB3B0 /* NCIntroViewController.swift in Sources */,
F7743A142C33F13A0034F670 /* NCCollectionViewCommon+CollectionViewDataSource.swift in Sources */,
F75B0ABD244C4DBB00E58DCA /* NCActionCenter.swift in Sources */,
Expand All @@ -4224,6 +4234,7 @@
F7802B322BD5584F00D74270 /* NCMedia+DragDrop.swift in Sources */,
F7EE66AD2A20B226009AE765 /* UILabel+Extension.swift in Sources */,
F78ACD4221903CE00088454D /* NCListCell.swift in Sources */,
F7BD0A002C468925003A4A6D /* NCMedia+CollectionViewDataSource.swift in Sources */,
F76D3CF12428B40E005DFA87 /* NCViewerPDFSearch.swift in Sources */,
F7245924289BB50C00474787 /* ThreadSafeDictionary.swift in Sources */,
F73F537F1E929C8500F8678D /* NCMore.swift in Sources */,
Expand Down Expand Up @@ -4368,6 +4379,7 @@
F76882302C0DD1E7001CF441 /* NCFileNameModel.swift in Sources */,
F72FD3B5297ED49A00075D28 /* NCManageDatabase+E2EE.swift in Sources */,
F73EF7CF2B0225BA0087E6E9 /* NCManageDatabase+Tag.swift in Sources */,
F7BD0A022C4689A4003A4A6D /* NCMedia+CollectionViewDelegate.swift in Sources */,
F3A047982BD2668800658E7B /* NCAssistantCreateNewTask.swift in Sources */,
AF93471227E2341B002537EE /* NCShare+Menu.swift in Sources */,
F7EFA47825ADBA500083159A /* NCViewerProviderContextMenu.swift in Sources */,
Expand Down
4 changes: 0 additions & 4 deletions Share/NCShareExtension+DataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ extension NCShareExtension: UICollectionViewDataSource {
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

guard let metadata = dataSource.cellForItemAt(indexPath: indexPath), let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as? NCListCell else {
return UICollectionViewCell()
}
Expand All @@ -92,7 +91,6 @@ extension NCShareExtension: UICollectionViewDataSource {
cell.fileUser = metadata.ownerId
cell.labelTitle.text = metadata.fileNameView
cell.labelTitle.textColor = NCBrandColor.shared.textColor

cell.imageSelect.image = nil
cell.imageStatus.image = nil
cell.imageLocal.image = nil
Expand All @@ -101,7 +99,6 @@ extension NCShareExtension: UICollectionViewDataSource {
cell.imageMore.image = nil
cell.imageItem.image = nil
cell.imageItem.backgroundColor = nil

cell.progressView.progress = 0.0

if metadata.directory {
Expand All @@ -117,7 +114,6 @@ extension NCShareExtension: UICollectionViewDataSource {
cell.backgroundView = nil
cell.hideButtonMore(true)
cell.hideButtonShare(true)
cell.selectMode(false)

// Live Photo
if metadata.isLivePhoto {
Expand Down
17 changes: 1 addition & 16 deletions Share/NCShareExtension+Files.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,9 @@ import UniformTypeIdentifiers

extension NCShareExtension {
@objc func reloadDatasource(withLoadFolder: Bool) {
var groupByField = "name"

layoutForView = NCManageDatabase.shared.setLayoutForView(account: activeAccount.account, key: keyLayout, serverUrl: serverUrl)

// set GroupField for Grid
if layoutForView?.layout == NCGlobal.shared.layoutGrid {
groupByField = "classFile"
}

let metadatas = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND directory == true", activeAccount.account, serverUrl))
self.dataSource = NCDataSource(
metadatas: metadatas,
account: activeAccount.account,
sort: layoutForView?.sort,
ascending: layoutForView?.ascending,
directoryOnTop: layoutForView?.directoryOnTop,
favoriteOnTop: true,
groupByField: groupByField)
self.dataSource = NCDataSource(metadatas: metadatas, account: activeAccount.account, layoutForView: layoutForView)

if withLoadFolder {
loadFolder()
Expand Down
10 changes: 9 additions & 1 deletion Share/NCShareExtension+NCDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ extension NCShareExtension: NCAccountRequestDelegate {
}

extension NCShareExtension: NCShareCellDelegate, NCRenameFileDelegate, NCListCellDelegate {

func removeFile(named fileName: String) {
guard let index = self.filesName.firstIndex(of: fileName) else {
return showAlert(title: "_file_not_found_", description: fileName)
Expand Down Expand Up @@ -139,6 +138,15 @@ extension NCShareExtension: NCShareCellDelegate, NCRenameFileDelegate, NCListCel
filesName[fileIx] = fileNameNew
tableView.reloadData()
}

func tapShareListItem(with objectId: String, indexPath: IndexPath, sender: Any) {
}

func tapMoreListItem(with objectId: String, namedButtonMore: String, image: UIImage?, indexPath: IndexPath, sender: Any) {
}

func longPressListItem(with objectId: String, indexPath: IndexPath, gestureRecognizer: UILongPressGestureRecognizer) {
}
}

extension NCShareExtension: NCCreateFormUploadConflictDelegate {
Expand Down
44 changes: 29 additions & 15 deletions iOSClient/Data/NCDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ class NCDataSource: NSObject {
var metadatas: [tableMetadata] = []
var metadatasForSection: [NCMetadataForSection] = []
var directory: tableDirectory?
var groupByField: String = ""
var groupBy: String?
var layout: String?

private let utilityFileSystem = NCUtilityFileSystem()
private var sectionsValue: [String] = []
private var providers: [NKSearchProvider]?
private var searchResults: [NKSearchResult]?
Expand All @@ -43,18 +45,25 @@ class NCDataSource: NSObject {
super.init()
}

init(metadatas: [tableMetadata], account: String, directory: tableDirectory? = nil, sort: String? = "none", ascending: Bool? = false, directoryOnTop: Bool? = true, favoriteOnTop: Bool? = true, groupByField: String = "name", providers: [NKSearchProvider]? = nil, searchResults: [NKSearchResult]? = nil) {
init(metadatas: [tableMetadata],
account: String,
directory: tableDirectory? = nil,
layoutForView: NCDBLayoutForView?,
favoriteOnTop: Bool = true,
providers: [NKSearchProvider]? = nil,
searchResults: [NKSearchResult]? = nil) {
super.init()

self.metadatas = metadatas.filter({
!(NCGlobal.shared.includeHiddenFiles.contains($0.fileNameView) || $0.isTransferInForeground)
})
self.directory = directory
self.sort = sort ?? "none"
self.ascending = ascending ?? false
self.directoryOnTop = directoryOnTop ?? true
self.favoriteOnTop = favoriteOnTop ?? true
self.groupByField = groupByField
self.sort = layoutForView?.sort ?? "none"
self.ascending = layoutForView?.ascending ?? false
self.directoryOnTop = layoutForView?.directoryOnTop ?? true
self.favoriteOnTop = favoriteOnTop
self.groupBy = layoutForView?.groupBy ?? "none"
self.layout = layoutForView?.layout
// unified search
self.providers = providers
self.searchResults = searchResults
Expand All @@ -77,9 +86,9 @@ class NCDataSource: NSObject {
self.directory = nil
}

func changeGroupByField(_ groupByField: String) {
self.groupByField = groupByField
print("DATASOURCE: set group by filed " + groupByField)
func changeGroupByField(_ groupBy: String) {
self.groupBy = groupBy
print("DATASOURCE: set group by filed " + groupBy)
self.metadatasForSection.removeAll()
self.sectionsValue.removeAll()
print("DATASOURCE: remove all sections")
Expand Down Expand Up @@ -108,8 +117,14 @@ class NCDataSource: NSObject {
if !self.sectionsValue.contains(section) {
self.sectionsValue.append(section)
}
// image Cache
if (layout == NCGlobal.shared.layoutPhotoRatio || layout == NCGlobal.shared.layoutPhotoSquare),
(metadata.isVideo || metadata.isImage),
NCImageCache.shared.getPreviewImageCache(ocId: metadata.ocId, etag: metadata.etag) == nil,
let image = UIImage(contentsOfFile: self.utilityFileSystem.getDirectoryProviderStoragePreviewOcId(metadata.ocId, etag: metadata.etag)) {
NCImageCache.shared.addPreviewImageCache(metadata: metadata, image: image)
}
}

// Unified search
if let providers = self.providers, !providers.isEmpty {
let sectionsDictionary = ThreadSafeDictionary<String, Int>()
Expand Down Expand Up @@ -248,13 +263,13 @@ class NCDataSource: NSObject {
}

internal func getSectionValue(metadata: tableMetadata) -> String {
switch self.groupByField {
case "name":
switch self.groupBy {
case "name", "none":
return NSLocalizedString(metadata.name, comment: "")
case "classFile":
return NSLocalizedString(metadata.classFile, comment: "").lowercased().firstUppercased
default:
return NSLocalizedString(metadata.classFile, comment: "")
return NSLocalizedString(metadata.name, comment: "")
}
}

Expand Down Expand Up @@ -339,7 +354,6 @@ class NCMetadataForSection: NSObject {
//
if sort != "none" && !sort.isEmpty {
metadatasSorted = metadatas.sorted {

switch sort {
case "date":
if ascending {
Expand Down
36 changes: 25 additions & 11 deletions iOSClient/Data/NCManageDatabase+LayoutForView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,23 @@ class NCDBLayoutForView: Object {
@Persisted var groupBy: String = "none"
@Persisted var directoryOnTop: Bool = true
@Persisted var titleButtonHeader: String = "_sorted_by_name_a_z_"
@Persisted var itemForLine: Int = 3
@Persisted var columnGrid: Int = 3
@Persisted var columnPhoto: Int = 3
}

extension NCManageDatabase {
@discardableResult
func setLayoutForView(account: String, key: String, serverUrl: String, layout: String? = nil, sort: String? = nil, ascending: Bool? = nil, groupBy: String? = nil, directoryOnTop: Bool? = nil, titleButtonHeader: String? = nil, itemForLine: Int? = nil) -> NCDBLayoutForView? {
func setLayoutForView(account: String,
key: String,
serverUrl: String,
layout: String? = nil,
sort: String? = nil,
ascending: Bool? = nil,
groupBy: String? = nil,
directoryOnTop: Bool? = nil,
titleButtonHeader: String? = nil,
columnGrid: Int? = nil,
columnPhoto: Int? = nil) -> NCDBLayoutForView? {
var keyStore = key
if !serverUrl.isEmpty { keyStore = serverUrl}
let index = account + " " + keyStore
Expand All @@ -56,29 +67,32 @@ extension NCManageDatabase {
}
addObject.account = account
addObject.keyStore = keyStore
if let layout = layout {
if let layout {
addObject.layout = layout
}
if let sort = sort {
if let sort {
addObject.sort = sort
}
if let sort = sort {
if let sort {
addObject.sort = sort
}
if let ascending = ascending {
if let ascending {
addObject.ascending = ascending
}
if let groupBy = groupBy {
if let groupBy {
addObject.groupBy = groupBy
}
if let directoryOnTop = directoryOnTop {
if let directoryOnTop {
addObject.directoryOnTop = directoryOnTop
}
if let titleButtonHeader = titleButtonHeader {
if let titleButtonHeader {
addObject.titleButtonHeader = titleButtonHeader
}
if let itemForLine = itemForLine {
addObject.itemForLine = itemForLine
if let columnGrid {
addObject.columnGrid = columnGrid
}
if let columnPhoto {
addObject.columnPhoto = columnPhoto
}
realm.add(addObject, update: .all)
}
Expand Down
10 changes: 1 addition & 9 deletions iOSClient/Favorites/NCFavorite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,7 @@ class NCFavorite: NCCollectionViewCommon {
metadatas = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", self.appDelegate.account, self.serverUrl))
}

self.dataSource = NCDataSource(metadatas: metadatas,
account: self.appDelegate.account,
sort: self.layoutForView?.sort,
ascending: self.layoutForView?.ascending,
directoryOnTop: self.layoutForView?.directoryOnTop,
favoriteOnTop: true,
groupByField: self.groupByField,
providers: self.providers,
searchResults: self.searchResults)
self.dataSource = NCDataSource(metadatas: metadatas, account: self.appDelegate.account, layoutForView: layoutForView, providers: self.providers, searchResults: self.searchResults)
}

override func reloadDataSourceNetwork(withQueryDB: Bool = false) {
Expand Down
13 changes: 1 addition & 12 deletions iOSClient/Files/NCFiles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class NCFiles: NCCollectionViewCommon {
self.selectOcId.removeAll()

self.layoutForView = NCManageDatabase.shared.getLayoutForView(account: self.appDelegate.account, key: self.layoutKey, serverUrl: self.serverUrl)
self.gridLayout.itemForLine = CGFloat(self.layoutForView?.itemForLine ?? 3)
if self.layoutForView?.layout == NCGlobal.shared.layoutList {
self.collectionView?.collectionViewLayout = self.listLayout
} else if self.layoutForView?.layout == NCGlobal.shared.layoutGrid {
Expand Down Expand Up @@ -113,17 +112,7 @@ class NCFiles: NCCollectionViewCommon {
}

self.richWorkspaceText = directory?.richWorkspace
self.dataSource = NCDataSource(
metadatas: metadatas,
account: self.appDelegate.account,
directory: directory,
sort: self.layoutForView?.sort,
ascending: self.layoutForView?.ascending,
directoryOnTop: self.layoutForView?.directoryOnTop,
favoriteOnTop: true,
groupByField: self.groupByField,
providers: self.providers,
searchResults: self.searchResults)
self.dataSource = NCDataSource(metadatas: metadatas, account: self.appDelegate.account, layoutForView: layoutForView, providers: self.providers, searchResults: self.searchResults)
}

override func reloadDataSource(withQueryDB: Bool = true) {
Expand Down
Loading
Loading