diff --git a/iOSClient/Activity/NCActivity.swift b/iOSClient/Activity/NCActivity.swift index 826fdc858d..02efd0c9a9 100644 --- a/iOSClient/Activity/NCActivity.swift +++ b/iOSClient/Activity/NCActivity.swift @@ -27,15 +27,12 @@ import SwiftRichString import NextcloudKit class NCActivity: UIViewController, NCSharePagingContent { - + @IBOutlet weak var viewContainerConstraint: NSLayoutConstraint! @IBOutlet weak var tableView: UITableView! var commentView: NCActivityCommentView? var textField: UIView? { commentView?.newCommentField } - - @IBOutlet weak var viewContainerConstraint: NSLayoutConstraint! var height: CGFloat = 0 - var metadata: tableMetadata? var showComments: Bool = false @@ -130,12 +127,8 @@ class NCActivity: UIViewController, NCSharePagingContent { label.textColor = NCBrandColor.shared.textColor2 label.textAlignment = .center label.text = NSLocalizedString("_no_activity_footer_", comment: "") -// label.frame = CGRect(x: 0, y: 10, width: tableView.frame.width, height: 60) - view.addSubview(label) - label.translatesAutoresizingMaskIntoConstraints = false - label.topAnchor.constraint(equalTo: view.topAnchor, constant: 20).isActive = true label.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true label.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true @@ -151,6 +144,10 @@ extension NCActivity: UITableViewDelegate { return 50 } + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + return 80 + } + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50)) view.backgroundColor = .clear @@ -187,7 +184,6 @@ extension NCActivity: UITableViewDelegate { } extension NCActivity: UITableViewDataSource { - func numberOfSections(in tableView: UITableView) -> Int { return sectionDates.count } @@ -248,7 +244,6 @@ extension NCActivity: UITableViewDataSource { guard let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath) as? NCActivityTableViewCell else { return UITableViewCell() } - var orderKeysId: [String] = [] cell.idActivity = activity.idActivity @@ -261,7 +256,6 @@ extension NCActivity: UITableViewDataSource { // icon if !activity.icon.isEmpty { - let fileNameIcon = (activity.icon as NSString).lastPathComponent let fileNameLocalPath = utilityFileSystem.directoryUserData + "/" + fileNameIcon @@ -283,12 +277,9 @@ extension NCActivity: UITableViewDataSource { // avatar if !activity.user.isEmpty && activity.user != appDelegate.userId { - cell.avatar.isHidden = false cell.fileUser = activity.user - let fileName = appDelegate.userBaseUrl + "-" + activity.user + ".png" - NCNetworking.shared.downloadAvatar(user: activity.user, dispalyName: nil, fileName: fileName, cell: cell, view: tableView) cell.subjectLeadingConstraint.constant = 15 } else { @@ -298,7 +289,6 @@ extension NCActivity: UITableViewDataSource { // subject cell.subject.text = activity.subject if !activity.subjectRich.isEmpty { - var subject = activity.subjectRich var keys: [String] = [] @@ -348,12 +338,11 @@ extension NCActivity: UIScrollViewDelegate { // MARK: - NC API & Algorithm extension NCActivity { - func fetchAll(isInitial: Bool) { guard !isFetchingActivity else { return } self.isFetchingActivity = true - var bottom: CGFloat = 0 + if let mainTabBar = self.tabBarController?.tabBar as? NCMainTabBar { bottom = -mainTabBar.getHeight() } @@ -380,8 +369,8 @@ extension NCActivity { } func loadDataSource() { - var newItems = [DateCompareable]() + if showComments, let metadata = metadata, let account = NCManageDatabase.shared.getActiveAccount() { let comments = NCManageDatabase.shared.getComments(account: account.account, objectId: metadata.fileId) newItems += comments @@ -453,10 +442,9 @@ extension NCActivity { func loadActivity(idActivity: Int, limit: Int = 200, disptachGroup: DispatchGroup) { guard hasActivityToLoad else { return } - var resultActivityId = 0 - disptachGroup.enter() + disptachGroup.enter() NextcloudKit.shared.getActivity( since: idActivity, limit: min(limit, 200), diff --git a/iOSClient/Activity/NCActivityCommentView.swift b/iOSClient/Activity/NCActivityCommentView.swift index 9318b90789..d308940641 100644 --- a/iOSClient/Activity/NCActivityCommentView.swift +++ b/iOSClient/Activity/NCActivityCommentView.swift @@ -42,7 +42,7 @@ class NCActivityCommentView: UIView, UITextFieldDelegate { imageItem.image = NCUtility().loadImage(named: "person.crop.circle", colors: [NCBrandColor.shared.iconImageColor]) } } -// + func textFieldShouldReturn(_ textField: UITextField) -> Bool { textField.resignFirstResponder() completionHandler?(textField.text) @@ -55,8 +55,6 @@ extension NCActivityCommentView: UISearchBarDelegate { searchBar.resignFirstResponder() completionHandler?(searchBar.text) } - func searchBarTextDidEndEditing(_ searchBar: UISearchBar) { -// return true - } + func searchBarTextDidEndEditing(_ searchBar: UISearchBar) { } } diff --git a/iOSClient/Activity/NCActivityTableViewCell.swift b/iOSClient/Activity/NCActivityTableViewCell.swift index 03661d6152..13aa77ace8 100644 --- a/iOSClient/Activity/NCActivityTableViewCell.swift +++ b/iOSClient/Activity/NCActivityTableViewCell.swift @@ -28,7 +28,6 @@ import JGProgressHUD import Queuer class NCActivityCollectionViewCell: UICollectionViewCell { - @IBOutlet weak var imageView: UIImageView! var fileId = "" @@ -83,19 +82,16 @@ class NCActivityTableViewCell: UITableViewCell, NCCellProtocol { // MARK: - Collection View extension NCActivityTableViewCell: UICollectionViewDelegate { - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - // Select not permitted if !didSelectItemEnable { return } - let activityPreview = activityPreviews[indexPath.row] if activityPreview.view == "trashbin" { - var responder: UIResponder? = collectionView + while !(responder is UIViewController) { responder = responder?.next if responder == nil { @@ -114,23 +110,19 @@ extension NCActivityTableViewCell: UICollectionViewDelegate { } } } - return } if activityPreview.view == NCGlobal.shared.appName && activityPreview.mimeType != "dir" { - guard let activitySubjectRich = NCManageDatabase.shared.getActivitySubjectRich(account: activityPreview.account, idActivity: activityPreview.idActivity, id: String(activityPreview.fileId)) else { return } - NCActionCenter.shared.viewerFile(account: appDelegate.account, fileId: activitySubjectRich.id, viewController: viewController) } } } extension NCActivityTableViewCell: UICollectionViewDataSource { - func numberOfSections(in collectionView: UICollectionView) -> Int { return 1 } @@ -141,7 +133,6 @@ extension NCActivityTableViewCell: UICollectionViewDataSource { } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let cell: NCActivityCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionCell", for: indexPath) as? NCActivityCollectionViewCell else { return UICollectionViewCell() } @@ -154,7 +145,6 @@ extension NCActivityTableViewCell: UICollectionViewDataSource { // Trashbin if activityPreview.view == "trashbin" { - let source = activityPreview.source utility.convertSVGtoPNGWriteToUserData(svgUrlString: source, width: 100, rewrite: false, account: appDelegate.account, id: idActivity) { imageNamePath, id in @@ -164,11 +154,8 @@ extension NCActivityTableViewCell: UICollectionViewDataSource { cell.imageView.image = NCImageCache.images.file } } - } else { - if activityPreview.isMimeTypeIcon { - let source = activityPreview.source utility.convertSVGtoPNGWriteToUserData(svgUrlString: source, width: 150, rewrite: false, account: appDelegate.account, id: idActivity) { imageNamePath, id in @@ -178,11 +165,8 @@ extension NCActivityTableViewCell: UICollectionViewDataSource { cell.imageView.image = NCImageCache.images.file } } - } else { - if let activitySubjectRich = NCManageDatabase.shared.getActivitySubjectRich(account: activityPreview.account, idActivity: idActivity, id: fileId) { - let fileNamePath = NCUtilityFileSystem().directoryUserData + "/" + activitySubjectRich.name if FileManager.default.fileExists(atPath: fileNamePath), let image = UIImage(contentsOfFile: fileNamePath) { @@ -201,14 +185,11 @@ extension NCActivityTableViewCell: UICollectionViewDataSource { } } } - return cell } - } extension NCActivityTableViewCell: UICollectionViewDelegateFlowLayout { - func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: 50, height: 30) } @@ -223,7 +204,6 @@ extension NCActivityTableViewCell: UICollectionViewDelegateFlowLayout { } class NCOperationDownloadThumbnailActivity: ConcurrentOperation { - var cell: NCActivityCollectionViewCell? var collectionView: UICollectionView? var fileNamePreviewLocalPath: String