Skip to content

Commit

Permalink
- SortBar: new allowMultiSelect property to control whether multi sel…
Browse files Browse the repository at this point in the history
…ect 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)
  • Loading branch information
felix-schwarz committed Apr 16, 2021
1 parent 002ee67 commit 4fddedf
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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 }

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
21 changes: 16 additions & 5 deletions ownCloudAppShared/Client/User Interface/SortBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4fddedf

Please sign in to comment.