From 6ebaf7e137834fa7720eab7a680d14aa2c847ded Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Thu, 30 May 2024 14:25:23 +0200 Subject: [PATCH] Version 5.3.1 (#2935) Signed-off-by: Nextcloud bot Signed-off-by: Marino Faggiana --- Nextcloud.xcodeproj/project.pbxproj | 8 +-- iOSClient/Extensions/Array+Extension.swift | 1 + iOSClient/Extensions/Data+Extension.swift | 1 + .../Extensions/DateFormatter+Extension.swift | 1 + iOSClient/Extensions/Optional+Extension.swift | 1 + .../UIAlertController+Extension.swift | 1 + .../Extensions/UIApplication+Extension.swift | 1 + .../Extensions/UIBarButton+Extension.swift | 1 + .../Extensions/UIControl+Extension.swift | 1 + iOSClient/Extensions/UIDevice+Extension.swift | 1 + iOSClient/Extensions/UIFont+Extension.swift | 1 + iOSClient/Extensions/UILabel+Extension.swift | 1 + .../UINavigationController+Extension.swift | 1 + .../UITabBarController+Extension.swift | 1 + .../Extensions/UIToolbar+Extension.swift | 1 + .../UIViewController+Extension.swift | 1 + ...ctionViewCommon+SelectTabBarDelegate.swift | 15 +++++- .../NCCollectionViewCommon.swift | 51 ++++++++++--------- iOSClient/SceneDelegate.swift | 2 +- .../Trash/NCTrash+SelectTabBarDelegate.swift | 7 ++- iOSClient/Trash/NCTrash.swift | 24 ++++----- iOSClient/Trash/NCTrashSelectTabBar.swift | 5 ++ 22 files changed, 81 insertions(+), 46 deletions(-) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index f18657a523..e0b33e3853 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -5264,7 +5264,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 21; + CURRENT_PROJECT_VERSION = 2; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -5290,7 +5290,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 5.3.0; + MARKETING_VERSION = 5.3.1; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = "-v"; OTHER_LDFLAGS = ""; @@ -5330,7 +5330,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 21; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -5353,7 +5353,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 5.3.0; + MARKETING_VERSION = 5.3.1; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = "-v"; OTHER_LDFLAGS = ""; diff --git a/iOSClient/Extensions/Array+Extension.swift b/iOSClient/Extensions/Array+Extension.swift index b88c33d38a..62a756ff51 100644 --- a/iOSClient/Extensions/Array+Extension.swift +++ b/iOSClient/Extensions/Array+Extension.swift @@ -23,6 +23,7 @@ // import Foundation +import UIKit // https://stackoverflow.com/questions/33861036/unique-objects-inside-a-array-swift/45023247#45023247 extension Array { diff --git a/iOSClient/Extensions/Data+Extension.swift b/iOSClient/Extensions/Data+Extension.swift index 1f228a4e63..77a77a23df 100644 --- a/iOSClient/Extensions/Data+Extension.swift +++ b/iOSClient/Extensions/Data+Extension.swift @@ -22,6 +22,7 @@ // import Foundation +import UIKit extension Data { diff --git a/iOSClient/Extensions/DateFormatter+Extension.swift b/iOSClient/Extensions/DateFormatter+Extension.swift index aa126ce786..dceb24e7e7 100644 --- a/iOSClient/Extensions/DateFormatter+Extension.swift +++ b/iOSClient/Extensions/DateFormatter+Extension.swift @@ -22,6 +22,7 @@ // import Foundation +import UIKit extension DateFormatter { static let shareExpDate: DateFormatter = { diff --git a/iOSClient/Extensions/Optional+Extension.swift b/iOSClient/Extensions/Optional+Extension.swift index 361a5acdfb..5a9b2e5f59 100644 --- a/iOSClient/Extensions/Optional+Extension.swift +++ b/iOSClient/Extensions/Optional+Extension.swift @@ -22,6 +22,7 @@ // import Foundation +import UIKit extension Optional where Wrapped: Collection { var isEmptyOrNil: Bool { diff --git a/iOSClient/Extensions/UIAlertController+Extension.swift b/iOSClient/Extensions/UIAlertController+Extension.swift index a2d10133ac..f75fac1cce 100644 --- a/iOSClient/Extensions/UIAlertController+Extension.swift +++ b/iOSClient/Extensions/UIAlertController+Extension.swift @@ -21,6 +21,7 @@ // along with this program. If not, see . // +import Foundation import UIKit import NextcloudKit diff --git a/iOSClient/Extensions/UIApplication+Extension.swift b/iOSClient/Extensions/UIApplication+Extension.swift index f82113323d..08a6a2df00 100644 --- a/iOSClient/Extensions/UIApplication+Extension.swift +++ b/iOSClient/Extensions/UIApplication+Extension.swift @@ -7,6 +7,7 @@ // import Foundation +import UIKit extension UIApplication { var firstWindow: UIWindow? { diff --git a/iOSClient/Extensions/UIBarButton+Extension.swift b/iOSClient/Extensions/UIBarButton+Extension.swift index 242c6e0e6b..7fb4b1c64a 100644 --- a/iOSClient/Extensions/UIBarButton+Extension.swift +++ b/iOSClient/Extensions/UIBarButton+Extension.swift @@ -22,6 +22,7 @@ // along with this program. If not, see . // +import Foundation import UIKit private var actionKey: Void? diff --git a/iOSClient/Extensions/UIControl+Extension.swift b/iOSClient/Extensions/UIControl+Extension.swift index 22431e5be5..3e11c2ad15 100644 --- a/iOSClient/Extensions/UIControl+Extension.swift +++ b/iOSClient/Extensions/UIControl+Extension.swift @@ -23,6 +23,7 @@ // import Foundation +import UIKit public class ActionClosure { diff --git a/iOSClient/Extensions/UIDevice+Extension.swift b/iOSClient/Extensions/UIDevice+Extension.swift index 64e819ac6d..5763365ee3 100644 --- a/iOSClient/Extensions/UIDevice+Extension.swift +++ b/iOSClient/Extensions/UIDevice+Extension.swift @@ -22,6 +22,7 @@ // import Foundation +import UIKit extension UIDevice { diff --git a/iOSClient/Extensions/UIFont+Extension.swift b/iOSClient/Extensions/UIFont+Extension.swift index 1465718620..ede832e2b7 100644 --- a/iOSClient/Extensions/UIFont+Extension.swift +++ b/iOSClient/Extensions/UIFont+Extension.swift @@ -21,6 +21,7 @@ // along with this program. If not, see . // +import Foundation import UIKit extension UIFont { diff --git a/iOSClient/Extensions/UILabel+Extension.swift b/iOSClient/Extensions/UILabel+Extension.swift index 1a39940adf..a2bd560f89 100644 --- a/iOSClient/Extensions/UILabel+Extension.swift +++ b/iOSClient/Extensions/UILabel+Extension.swift @@ -21,6 +21,7 @@ // along with this program. If not, see . // +import Foundation import UIKit // diff --git a/iOSClient/Extensions/UINavigationController+Extension.swift b/iOSClient/Extensions/UINavigationController+Extension.swift index ec3f4fca68..0f1e97acb9 100644 --- a/iOSClient/Extensions/UINavigationController+Extension.swift +++ b/iOSClient/Extensions/UINavigationController+Extension.swift @@ -22,6 +22,7 @@ // import Foundation +import UIKit extension UINavigationController { diff --git a/iOSClient/Extensions/UITabBarController+Extension.swift b/iOSClient/Extensions/UITabBarController+Extension.swift index 66e57c5358..e2901e9ff8 100644 --- a/iOSClient/Extensions/UITabBarController+Extension.swift +++ b/iOSClient/Extensions/UITabBarController+Extension.swift @@ -22,6 +22,7 @@ // import Foundation +import UIKit extension UITabBarController { diff --git a/iOSClient/Extensions/UIToolbar+Extension.swift b/iOSClient/Extensions/UIToolbar+Extension.swift index 53e63fca1b..3f1f36fcaf 100644 --- a/iOSClient/Extensions/UIToolbar+Extension.swift +++ b/iOSClient/Extensions/UIToolbar+Extension.swift @@ -21,6 +21,7 @@ // along with this program. If not, see . // +import Foundation import UIKit extension UIToolbar { diff --git a/iOSClient/Extensions/UIViewController+Extension.swift b/iOSClient/Extensions/UIViewController+Extension.swift index 172dccb038..98be0e968d 100644 --- a/iOSClient/Extensions/UIViewController+Extension.swift +++ b/iOSClient/Extensions/UIViewController+Extension.swift @@ -22,6 +22,7 @@ // import Foundation +import UIKit extension UIViewController { diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+SelectTabBarDelegate.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+SelectTabBarDelegate.swift index f16dcce1a0..97b2fb8976 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+SelectTabBarDelegate.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+SelectTabBarDelegate.swift @@ -21,6 +21,7 @@ // along with this program. If not, see . // +import UIKit import Foundation import NextcloudKit @@ -161,7 +162,7 @@ extension NCCollectionViewCommon: NCCollectionViewCommonSelectTabBarDelegate { func saveLayout(_ layoutForView: NCDBLayoutForView) { NCManageDatabase.shared.setLayoutForView(layoutForView: layoutForView) NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource) - setNavigationRightItems(enableMenu: false) + setNavigationRightItems() } func getSelectedMetadatas() -> [tableMetadata] { @@ -176,7 +177,17 @@ extension NCCollectionViewCommon: NCCollectionViewCommonSelectTabBarDelegate { func setEditMode(_ editMode: Bool) { isEditMode = editMode selectOcId.removeAll() - setNavigationRightItems(enableMenu: !editMode) + + if editMode { + navigationItem.leftBarButtonItems = nil + } else { + setNavigationLeftItems() + } + setNavigationRightItems() + + navigationController?.interactivePopGestureRecognizer?.isEnabled = !editMode + navigationItem.hidesBackButton = editMode + searchController(enabled: !editMode) collectionView.reloadData() } } diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 5e1c1c3bf6..90147abf63 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -160,6 +160,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS navigationController?.setNavigationBarHidden(false, animated: true) navigationItem.title = titleCurrentFolder + isEditMode = false setNavigationLeftItems() setNavigationRightItems() @@ -214,7 +215,6 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS NCNetworking.shared.cancelUnifiedSearchFiles() dismissTip() - setEditMode(false) // Cancel Queue & Retrieves Properties NCNetworking.shared.downloadThumbnailQueue.cancelAll() @@ -651,7 +651,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS navigationItem.title = titleCurrentFolder } - func setNavigationRightItems(enableMenu: Bool = false) { + func setNavigationRightItems() { guard layoutKey != NCGlobal.shared.layoutViewTransfers else { return } let isTabBarHidden = self.tabBarController?.tabBar.isHidden ?? true let isTabBarSelectHidden = tabBarSelect.isHidden() @@ -746,25 +746,23 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS self.setEditMode(false) } navigationItem.rightBarButtonItems = [select] - } else { + } else if navigationItem.rightBarButtonItems == nil || (!isEditMode && !tabBarSelect.isHidden()) { tabBarSelect.hide() - if navigationItem.rightBarButtonItems == nil || enableMenu { - let menuButton = UIBarButtonItem(image: utility.loadImage(named: "ellipsis.circle"), menu: UIMenu(children: createMenuActions())) - menuButton.tintColor = NCBrandColor.shared.iconImageColor - if layoutKey == NCGlobal.shared.layoutViewFiles { - let notification = UIBarButtonItem(image: utility.loadImage(named: "bell"), style: .plain) { - if let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification { - self.navigationController?.pushViewController(viewController, animated: true) - } + let menuButton = UIBarButtonItem(image: utility.loadImage(named: "ellipsis.circle"), menu: UIMenu(children: createMenuActions())) + menuButton.tintColor = NCBrandColor.shared.iconImageColor + if layoutKey == NCGlobal.shared.layoutViewFiles { + let notification = UIBarButtonItem(image: utility.loadImage(named: "bell"), style: .plain) { + if let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification { + self.navigationController?.pushViewController(viewController, animated: true) } - notification.tintColor = NCBrandColor.shared.iconImageColor - navigationItem.rightBarButtonItems = [menuButton, notification] - } else { - navigationItem.rightBarButtonItems = [menuButton] } + notification.tintColor = NCBrandColor.shared.iconImageColor + navigationItem.rightBarButtonItems = [menuButton, notification] } else { - navigationItem.rightBarButtonItems?.first?.menu = navigationItem.rightBarButtonItems?.first?.menu?.replacingChildren(createMenuActions()) + navigationItem.rightBarButtonItems = [menuButton] } + } else { + navigationItem.rightBarButtonItems?.first?.menu = navigationItem.rightBarButtonItems?.first?.menu?.replacingChildren(createMenuActions()) } // fix, if the tabbar was hidden before the update, set it in hidden if isTabBarHidden, isTabBarSelectHidden { @@ -783,30 +781,37 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS // MARK: - SEARCH + func searchController(enabled: Bool) { + guard enableSearchBar else { return } + searchController?.searchBar.isUserInteractionEnabled = enabled + if enabled { + searchController?.searchBar.alpha = 1 + } else { + searchController?.searchBar.alpha = 0.3 + + } + } + func updateSearchResults(for searchController: UISearchController) { self.literalSearch = searchController.searchBar.text } func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) { - isSearchingMode = true self.providers?.removeAll() self.dataSource.clearDataSource() self.collectionView.reloadData() - // TIP dismissTip() } func searchBarTextDidEndEditing(_ searchBar: UISearchBar) { - if isSearchingMode && self.literalSearch?.count ?? 0 >= 2 { reloadDataSourceNetwork() } } func searchBarCancelButtonClicked(_ searchBar: UISearchBar) { - DispatchQueue.global().async { NCNetworking.shared.cancelUnifiedSearchFiles() self.isSearchingMode = false @@ -824,14 +829,12 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS } func tapShareListItem(with objectId: String, indexPath: IndexPath, sender: Any) { - if isEditMode { return } guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId) else { return } NCActionCenter.shared.openShare(viewController: self, metadata: metadata, page: .sharing) } func tapMoreGridItem(with objectId: String, namedButtonMore: String, image: UIImage?, indexPath: IndexPath, sender: Any) { - if isEditMode { return } guard let metadata = NCManageDatabase.shared.getMetadataFromOcId(objectId) else { return } if namedButtonMore == NCGlobal.shared.buttonMoreMore || namedButtonMore == NCGlobal.shared.buttonMoreLock { @@ -1704,7 +1707,9 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { var height: CGFloat = 0 - if dataSource.getMetadataSourceForAllSections().isEmpty { + if isEditMode { + return CGSize.zero + } else if dataSource.getMetadataSourceForAllSections().isEmpty { height = NCGlobal.shared.getHeightHeaderEmptyData(view: view, portraitOffset: emptyDataPortaitOffset, landscapeOffset: emptyDataLandscapeOffset, isHeaderMenuTransferViewEnabled: isHeaderMenuTransferViewEnabled()) } else { let (heightHeaderCommands, heightHeaderRichWorkspace, heightHeaderSection) = getHeaderHeight(section: section) diff --git a/iOSClient/SceneDelegate.swift b/iOSClient/SceneDelegate.swift index b1e3d47f56..3c54cc63da 100644 --- a/iOSClient/SceneDelegate.swift +++ b/iOSClient/SceneDelegate.swift @@ -21,7 +21,7 @@ // along with this program. If not, see . // -import Foundation +import UIKit import NextcloudKit import WidgetKit import SwiftEntryKit diff --git a/iOSClient/Trash/NCTrash+SelectTabBarDelegate.swift b/iOSClient/Trash/NCTrash+SelectTabBarDelegate.swift index 082de8be95..557e707745 100644 --- a/iOSClient/Trash/NCTrash+SelectTabBarDelegate.swift +++ b/iOSClient/Trash/NCTrash+SelectTabBarDelegate.swift @@ -69,7 +69,12 @@ extension NCTrash: NCTrashSelectTabBarDelegate { func setEditMode(_ editMode: Bool) { isEditMode = editMode selectOcId.removeAll() - setNavigationRightItems(enableMenu: !editMode) + + setNavigationRightItems() + + navigationController?.interactivePopGestureRecognizer?.isEnabled = !editMode + navigationItem.hidesBackButton = editMode collectionView.reloadData() + } } diff --git a/iOSClient/Trash/NCTrash.swift b/iOSClient/Trash/NCTrash.swift index be4b5c253d..d918a1e278 100644 --- a/iOSClient/Trash/NCTrash.swift +++ b/iOSClient/Trash/NCTrash.swift @@ -76,8 +76,6 @@ class NCTrash: UIViewController, NCTrashListCellDelegate, NCTrashGridCellDelegat refreshControl.tintColor = NCBrandColor.shared.textColor2 refreshControl.addTarget(self, action: #selector(loadListingTrash), for: .valueChanged) - setNavigationRightItems() - NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSource), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterReloadDataSource), object: nil) } @@ -94,6 +92,9 @@ class NCTrash: UIViewController, NCTrashListCellDelegate, NCTrashGridCellDelegat collectionView.collectionViewLayout = gridLayout } + isEditMode = false + setNavigationRightItems() + reloadDataSource() loadListingTrash() } @@ -106,11 +107,6 @@ class NCTrash: UIViewController, NCTrashListCellDelegate, NCTrashGridCellDelegat dataSourceTask?.cancel() } - override func viewDidDisappear(_ animated: Bool) { - super.viewDidDisappear(animated) - setEditMode(false) - } - override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) @@ -129,7 +125,7 @@ class NCTrash: UIViewController, NCTrashListCellDelegate, NCTrashGridCellDelegat // MARK: - Layout - func setNavigationRightItems(enableMenu: Bool = false) { + func setNavigationRightItems() { func createMenuActions() -> [UIMenuElement] { guard let layoutForView = NCManageDatabase.shared.getLayoutForView(account: appDelegate.account, key: layoutKey, serverUrl: "") else { return [] } let select = UIAction(title: NSLocalizedString("_select_", comment: ""), image: utility.loadImage(named: "checkmark.circle", colors: [NCBrandColor.shared.iconImageColor]), attributes: self.datasource.isEmpty ? .disabled : []) { _ in @@ -155,14 +151,12 @@ class NCTrash: UIViewController, NCTrashListCellDelegate, NCTrashGridCellDelegat self.setEditMode(false) } navigationItem.rightBarButtonItems = [select] - } else { + } else if navigationItem.rightBarButtonItems == nil || (!isEditMode && !tabBarSelect.isHidden()) { tabBarSelect.hide() - if navigationItem.rightBarButtonItems == nil || enableMenu { - let menu = UIBarButtonItem(image: utility.loadImage(named: "ellipsis.circle", colors: [NCBrandColor.shared.iconImageColor]), menu: UIMenu(children: createMenuActions())) - navigationItem.rightBarButtonItems = [menu] - } else { - navigationItem.rightBarButtonItems?.first?.menu = navigationItem.rightBarButtonItems?.first?.menu?.replacingChildren(createMenuActions()) - } + let menu = UIBarButtonItem(image: utility.loadImage(named: "ellipsis.circle", colors: [NCBrandColor.shared.iconImageColor]), menu: UIMenu(children: createMenuActions())) + navigationItem.rightBarButtonItems = [menu] + } else { + navigationItem.rightBarButtonItems?.first?.menu = navigationItem.rightBarButtonItems?.first?.menu?.replacingChildren(createMenuActions()) } } diff --git a/iOSClient/Trash/NCTrashSelectTabBar.swift b/iOSClient/Trash/NCTrashSelectTabBar.swift index 54c6a26b6e..1c48a6e499 100644 --- a/iOSClient/Trash/NCTrashSelectTabBar.swift +++ b/iOSClient/Trash/NCTrashSelectTabBar.swift @@ -78,6 +78,11 @@ class NCTrashSelectTabBar: ObservableObject { func update(selectOcId: [String]) { isSelectedEmpty = selectOcId.isEmpty } + + func isHidden() -> Bool { + guard let hostingController else { return false } + return hostingController.view.isHidden + } } struct NCTrashSelectTabBarView: View {