From 4fddedfdebd13fe48d8b1b48d9d00682c575e512 Mon Sep 17 00:00:00 2001 From: Felix Schwarz Date: Fri, 16 Apr 2021 13:01:33 +0200 Subject: [PATCH] - SortBar: new allowMultiSelect property to control whether multi select should be available, defaulting to true - QueryFileListTableViewController, ClientQueryViewController: allow efficient subclassing of relevant parts of the reveal feature - ClientDirectoryPickerViewController: provide implementations of relevant reveal subclassing points, disable multi-select (fixing finding (7) and (9) in #933) --- .../ClientDirectoryPickerViewController.swift | 23 +++++++++++++------ .../ClientQueryViewController.swift | 2 +- .../QueryFileListTableViewController.swift | 8 +++++-- .../Client/User Interface/SortBar.swift | 21 +++++++++++++---- 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/ownCloudAppShared/Client/File Lists/ClientDirectoryPickerViewController.swift b/ownCloudAppShared/Client/File Lists/ClientDirectoryPickerViewController.swift index 3f3459814..b97f32780 100644 --- a/ownCloudAppShared/Client/File Lists/ClientDirectoryPickerViewController.swift +++ b/ownCloudAppShared/Client/File Lists/ClientDirectoryPickerViewController.swift @@ -143,7 +143,7 @@ open class ClientDirectoryPickerViewController: ClientQueryViewController { // Cancel button creation cancelBarButton = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(cancelBarButtonPressed)) - sortBar?.showSelectButton = false + sortBar?.allowMultiSelect = false tableView.dragInteractionEnabled = false } @@ -170,12 +170,6 @@ open class ClientDirectoryPickerViewController: ClientQueryViewController { } } - override open func viewWillDisappear(_ animated: Bool) { - super.viewWillDisappear(animated) - - sortBar?.showSelectButton = false - } - private func allowNavigationFor(item: OCItem?) -> Bool { guard let item = item else { return false } @@ -264,6 +258,7 @@ open class ClientDirectoryPickerViewController: ClientQueryViewController { let pickerController = ClientDirectoryPickerViewController(core: core, path: path, selectButtonTitle: selectButtonTitle, allowedPathFilter: allowedPathFilter, navigationPathFilter: navigationPathFilter, choiceHandler: choiceHandler) pickerController.cancelAction = cancelAction + pickerController.breadCrumbsPush = self.breadCrumbsPush self.navigationController?.pushViewController(pickerController, animated: true) } @@ -370,4 +365,18 @@ open class ClientDirectoryPickerViewController: ClientQueryViewController { super.queryHasChangesAvailable(query) } } + + public override func revealViewController(core: OCCore, path: String, item: OCItem, rootViewController: UIViewController?) -> UIViewController? { + guard let selectButtonTitle = selectButtonTitle, let choiceHandler = choiceHandler else { + return nil + } + + let pickerController = ClientDirectoryPickerViewController(core: core, path: path, selectButtonTitle: selectButtonTitle, allowedPathFilter: allowedPathFilter, navigationPathFilter: navigationPathFilter, choiceHandler: choiceHandler) + + pickerController.revealItemLocalID = item.localID + pickerController.cancelAction = cancelAction + pickerController.breadCrumbsPush = true + + return pickerController + } } diff --git a/ownCloudAppShared/Client/File Lists/ClientQueryViewController.swift b/ownCloudAppShared/Client/File Lists/ClientQueryViewController.swift index fa6798314..8700ef437 100644 --- a/ownCloudAppShared/Client/File Lists/ClientQueryViewController.swift +++ b/ownCloudAppShared/Client/File Lists/ClientQueryViewController.swift @@ -42,7 +42,7 @@ open class ClientQueryViewController: QueryFileListTableViewController, UIDropIn weak public var clientRootViewController : UIViewController? private var _actionProgressHandler : ActionProgressHandler? - private var revealItemLocalID : String? + public var revealItemLocalID : String? private var revealItemFound : Bool = false private let ItemDataUTI = "com.owncloud.ios-app.item-data" diff --git a/ownCloudAppShared/Client/File Lists/QueryFileListTableViewController.swift b/ownCloudAppShared/Client/File Lists/QueryFileListTableViewController.swift index 8140023f0..8769f6092 100644 --- a/ownCloudAppShared/Client/File Lists/QueryFileListTableViewController.swift +++ b/ownCloudAppShared/Client/File Lists/QueryFileListTableViewController.swift @@ -450,9 +450,13 @@ open class QueryFileListTableViewController: FileListTableViewController, SortBa return cell! } + public func revealViewController(core: OCCore, path: String, item: OCItem, rootViewController: UIViewController?) -> UIViewController? { + return ClientQueryViewController(core: core, query: OCQuery(forPath: path), reveal: item, rootViewController: nil) + } + public func reveal(item: OCItem, core: OCCore, sender: AnyObject?) -> Bool { - if let parentPath = item.path?.parentPath { - let revealQueryViewController = ClientQueryViewController(core: core, query: OCQuery(forPath: parentPath), reveal: item, rootViewController: nil) + if let parentPath = item.path?.parentPath, + let revealQueryViewController = revealViewController(core: core, path: parentPath, item: item, rootViewController: nil) { self.navigationController?.pushViewController(revealQueryViewController, animated: true) diff --git a/ownCloudAppShared/Client/User Interface/SortBar.swift b/ownCloudAppShared/Client/User Interface/SortBar.swift index e61aa7179..51855784c 100644 --- a/ownCloudAppShared/Client/User Interface/SortBar.swift +++ b/ownCloudAppShared/Client/User Interface/SortBar.swift @@ -89,16 +89,27 @@ public class SortBar: UIView, Themeable, UIPopoverPresentationControllerDelegate public var sortButton: UIButton? public var searchScopeSegmentedControl : SegmentedControl? public var selectButton: UIButton? + public var allowMultiSelect: Bool = true { + didSet { + updateSelectButtonVisibility() + } + } public var showSelectButton: Bool = false { didSet { - selectButton?.isHidden = !showSelectButton - selectButton?.accessibilityElementsHidden = !showSelectButton - selectButton?.isEnabled = showSelectButton - - UIAccessibility.post(notification: .layoutChanged, argument: nil) + updateSelectButtonVisibility() } } + private func updateSelectButtonVisibility() { + let showButton = showSelectButton && allowMultiSelect + + selectButton?.isHidden = !showButton + selectButton?.accessibilityElementsHidden = !showButton + selectButton?.isEnabled = showButton + + UIAccessibility.post(notification: .layoutChanged, argument: nil) + } + var showSearchScope: Bool = false { didSet { showSelectButton = !self.showSearchScope