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

[feature/sharing-user-groups] Implementation of Sharing with Users, Groups and Remote Users, Public Links #358

Merged
merged 144 commits into from
Jun 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
d0d21c0
#351 added first draft of Sharing with users, groups, remotes
hosy Apr 12, 2019
fcce307
- changes for shared with user handling
hosy Apr 17, 2019
9a7bc50
- added icon in file list, if item is shared
hosy Apr 18, 2019
33555b5
setting permissions is now working
hosy Apr 18, 2019
62fab58
using correct sdk commit
hosy Apr 18, 2019
1915662
changed query, if item is shared
hosy Apr 18, 2019
8902510
- search for recipients
hosy Apr 20, 2019
278c2c6
removed deleted SharingSearchResults Controller
hosy Apr 20, 2019
4168fc4
- removed unneeded elements
hosy Apr 20, 2019
8df0575
- fixed crash on adding recipient to share
hosy Apr 21, 2019
20846db
- added activity view when searching shares
hosy Apr 22, 2019
293bc87
fixed Theming for searchBar and selecting rows
hosy Apr 22, 2019
22d2d73
- moved MessageView to own class
hosy Apr 23, 2019
fe1dff3
- Add menu: left aligned text, added icons
hosy Apr 29, 2019
efaabe8
- fixed missing sharing row
hosy Apr 29, 2019
94e0482
- changed image alignment
hosy Apr 29, 2019
94c6a53
- fixed wrong usage of Sharing SDK-API
hosy Apr 30, 2019
1463ac3
Merge commit '8b86fc194029ab065d5fb7cc1ba4b4184a7d134e' into feature/…
hosy Apr 30, 2019
a91ef8a
- fixed delete recipient, only if user has permissions
hosy Apr 30, 2019
327c689
added activity indicator to searchbar
hosy Apr 30, 2019
f68a758
- implemented public link sharing (WIP)
hosy May 2, 2019
e51eee7
- fixed date picker row disable handling
hosy May 3, 2019
671f6de
- using new SDK with support share.protectedByPassword
hosy May 3, 2019
212f2dd
Merge branch 'master' into feature/sharing-user-groups
hosy May 3, 2019
69be864
removed merging with master problems
hosy May 3, 2019
ab0ec46
- password fixed
hosy May 3, 2019
156920f
- fixed creating public link
hosy May 3, 2019
4da3eaa
added capability support for sharing/public links
hosy May 6, 2019
e4e2cf1
- fixed missing expire date switch
hosy May 6, 2019
c3ece95
- fixed wrong sharing logic
hosy May 6, 2019
775ceb0
- fixed keyboard focus for searchbar
hosy May 7, 2019
f42e7d7
- changed sharing icon
hosy May 7, 2019
40de26f
code refactoring
hosy May 7, 2019
a3b4e0d
- using new SDK, which fixes URL encoding problems
hosy May 7, 2019
b78f81e
- determine, if an item is shared by user or group
hosy May 7, 2019
3656d77
- added an action event, when the text field action should be performed
hosy May 7, 2019
7fed294
added action event for name text field
hosy May 7, 2019
eec5a08
- fixed, when showing share rows
hosy May 8, 2019
5e65b9e
code refactoring
hosy May 8, 2019
c5b3f0a
- fixed setting share permissions for edit row
hosy May 8, 2019
b22c827
- changed edit permissions handling (only show change, create, delete…
hosy May 9, 2019
5607d4c
use correct new created share
hosy May 9, 2019
1295655
- added item header to sharing overview
hosy May 10, 2019
f99d05a
fixed searchDisplayName
hosy May 10, 2019
d4c8ae9
- use new SDK, which supports pending shares, ...
hosy May 13, 2019
10e6242
set correct table row titles
hosy May 13, 2019
aaab71f
- changed Library to Quick Access
hosy May 14, 2019
05d074f
- added pending cloud shares
hosy May 14, 2019
df37b65
added accepted cloud shares, to "Shared with me"
hosy May 14, 2019
b6dbf6a
- using new SDK with fixed Favorite support
hosy May 14, 2019
5cb195b
Merge branch 'master' into feature/sharing-user-groups
hosy May 14, 2019
5946f12
- fixed group sharing
hosy May 14, 2019
b74cfcb
fixed main thread crash
hosy May 14, 2019
b6c4281
Merge branch 'master' into feature/sharing-user-groups
hosy May 15, 2019
8a81be4
- show shared items only unique, if it was shared to more receipients
hosy May 15, 2019
225b7ee
Merge branch 'master' into feature/sharing-user-groups
hosy May 15, 2019
bc3595f
code refactoring from code review
hosy May 15, 2019
28ed34f
code refactoring for code review
hosy May 15, 2019
587b3ca
- added missing localization strings
hosy May 16, 2019
130a866
- subclass for ClientItemCell, which retrieves OCItem by OCShare path…
hosy May 16, 2019
6e38b09
- using new SDK with refresh for favorites support
hosy May 16, 2019
2d54bf4
set default values from OCShare until OCItem is loaded
hosy May 16, 2019
8acddd2
- added themable background to custom file list
hosy May 16, 2019
7a11c90
code review changes
hosy May 20, 2019
db2404c
- added header title to "Copy URL" table view row, to show the link U…
hosy May 20, 2019
ad53701
show header label as multiline, because of long urls
hosy May 20, 2019
b70db37
- fixed setting favorite state
hosy May 20, 2019
fbd20cc
fixed updating preferred content size in cardview for shares
hosy May 20, 2019
3300530
show image (group, person) for recipient search results
hosy May 20, 2019
56384a0
added missing translation string from clear storage
hosy May 21, 2019
69b8643
mostly retain cycles, fixed cardViewController content size, constrai…
hosy May 22, 2019
05a95b3
Merge branch 'master' into feature/sharing-user-groups
hosy May 22, 2019
4e819bf
new wording for sharing and some logical changes for sharing UI
hosy May 22, 2019
481ed24
fixed failed merge conflicts
hosy May 22, 2019
1e94748
- creating shares and public links needs confirmation, before creating
hosy May 22, 2019
1f9e4ac
disable table scrolling for quick access view
hosy May 22, 2019
f849d7c
- fixed constraint problems
hosy May 23, 2019
7465a80
If link will be created, share button is not needed
hosy May 23, 2019
b33e0a6
- fixed wording
hosy May 23, 2019
85e6cd8
- Break various retain cycles
felix-schwarz May 23, 2019
7574732
- Add missing constraint to UITableViewController+Extension.swift
felix-schwarz May 23, 2019
fe971f9
- Refactor item lists to new class tree:
felix-schwarz May 24, 2019
bc1e842
- Adding missing copyright notes, minor improvements
felix-schwarz May 24, 2019
55acc7f
- Continue refactoring of file lists
felix-schwarz May 24, 2019
492e622
- Fix accepted cloud shares being dropped if the list of items shared…
felix-schwarz May 24, 2019
5e58461
- Fix issues in LibraryTableViewController
felix-schwarz May 24, 2019
6fce2ec
- simplify .filter() blocks
felix-schwarz May 24, 2019
463d583
- Add "Pending" placeholder for negative item sizes
felix-schwarz May 24, 2019
a2f0882
- Rename CustomFileListTableViewController to LibraryFilesTableViewCo…
felix-schwarz May 25, 2019
4fbce63
- Consolidate NSLayoutConstraint activation in HeaderActionTableViewC…
felix-schwarz May 25, 2019
030b3a1
code review changes
hosy May 27, 2019
f6d3fbb
- Update SDK
felix-schwarz May 27, 2019
df6c296
Merge remote-tracking branch 'origin/master' into feature/sharing-use…
felix-schwarz May 27, 2019
d1e07af
- Remove non-existant TVG file references
felix-schwarz May 27, 2019
0dc6de8
fixed QA finding (2):
hosy May 28, 2019
ef78f7b
Merge branch 'feature/sharing-user-groups' of github.com:owncloud/ios…
hosy May 28, 2019
26ba699
QA finding (2)
hosy May 28, 2019
be05318
Merge branch 'master' into feature/sharing-user-groups
hosy May 29, 2019
36be52c
QA finding (3) exclude current collaborators from recipient search
hosy May 29, 2019
ebb29e5
QA finding (7) fixed setting edit permissions and hide/show/selecting…
hosy May 29, 2019
1927977
- Refactor ClientDirectoryPickerViewController to follow best practic…
felix-schwarz May 29, 2019
fb64147
QA finding (8): remove race condition for permission changes
hosy May 29, 2019
9ac2226
- Added ClientDirectoryPickerViewController.navigationPathFilter to a…
felix-schwarz May 29, 2019
40c8b5e
QA finding (12) fixed inherit correct resharing permissions
hosy May 29, 2019
268b9a5
QA finding (13) fixed, long filenames and date is now visible
hosy May 29, 2019
ebfd702
- added "Invite Collaborator", if item is not shared to overview
hosy May 29, 2019
c1f94a8
Merge branch 'feature/sharing-user-groups' of github.com:owncloud/ios…
hosy May 29, 2019
1bce170
only show decline alert, if share is remote type
hosy May 29, 2019
26403da
- Fixing ClientRootViewController issues
felix-schwarz May 31, 2019
76c1a95
- Updated ios-sdk adding recursive deletion of items in the metaData …
felix-schwarz May 31, 2019
79c14a6
- added possibility to retrieve more text field delegate actions
hosy Jun 3, 2019
206adf8
fixed wording
hosy Jun 3, 2019
73b2c03
- setting default expire date
hosy Jun 3, 2019
cc4f6f4
changed wording "Save" to "Create"
hosy Jun 3, 2019
ed494cd
fixed removing expiration date
hosy Jun 3, 2019
17b01c6
- fixed counting default link name
hosy Jun 3, 2019
810bea6
fixed setting expiration date in create mode
hosy Jun 3, 2019
4047bd7
QA finding 25: if password is required, hide password switch and sho…
hosy Jun 3, 2019
dc21689
QA finding (12) fixed hiding UI elements, if resharing is not allowed
hosy Jun 4, 2019
3258cbc
QA finding (15) (16) changed behavior of copy link
hosy Jun 4, 2019
bfd86d3
new unshare extension, which is showing in card menu instead of delet…
hosy Jun 4, 2019
f115830
new wording for sharing an item
hosy Jun 4, 2019
3e017a6
fixed text color in search text field
hosy Jun 5, 2019
f7068c2
fixed disable password switch for initial setup, if password is enforced
hosy Jun 5, 2019
bbd8e3c
fixed enumeration of public link names
hosy Jun 5, 2019
45fda92
if public link name is empty, use token as name in overview
hosy Jun 5, 2019
4e6fb95
hide permission "Share" in description, if resharing capability is no…
hosy Jun 5, 2019
89005ec
new SDK for fixing the default expiration date (was not set before in…
hosy Jun 5, 2019
a2549c2
unshare cloud shares fixed
hosy Jun 5, 2019
9930326
update share queries, after accept/decline remote share
hosy Jun 5, 2019
bedfd20
new traitCollection for vertical compact size class, because labels w…
hosy Jun 5, 2019
6b3516e
- fixed large titles in child view controller
hosy Jun 5, 2019
d1d4d8e
fixed adding default expiration dates to current date
hosy Jun 6, 2019
7a7c081
- Update ios-sdk to address issue (30) in #358
felix-schwarz Jun 6, 2019
f730171
- Fix issue (10) in #358 via SDK
felix-schwarz Jun 6, 2019
50e767a
fixed QA finding (32), that only one pending invite was shown, if mor…
hosy Jun 6, 2019
2ea337d
fixed QA finding (27), MessageView has a left and right padding, whic…
hosy Jun 6, 2019
a951f4d
Merge branch 'feature/sharing-user-groups' of github.com:owncloud/ios…
hosy Jun 6, 2019
b8b1c60
- Correctly handle local user names ending with an "@" (via SDK update)
felix-schwarz Jun 7, 2019
2982081
- Added OCItem array extension .sharedWithUser
felix-schwarz Jun 7, 2019
c06f6b9
- Added new OCItem.shareRootItem(from: core) and OCItem.isShareRootIt…
felix-schwarz Jun 7, 2019
e6f32cc
fixed QA finding (35), show options, if not set in default permission…
hosy Jun 7, 2019
668fdae
- enable "Links" menu item, if public link sharing is disabled
hosy Jun 7, 2019
633b098
- only show link menu item, if bookmark is online
hosy Jun 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 99 additions & 15 deletions ownCloud.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
1 change: 1 addition & 0 deletions ownCloud/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
OCExtensionManager.shared.addExtension(CopyAction.actionExtension)
OCExtensionManager.shared.addExtension(UploadFileAction.actionExtension)
OCExtensionManager.shared.addExtension(UploadMediaAction.actionExtension)
OCExtensionManager.shared.addExtension(UnshareAction.actionExtension)

Theme.shared.activeCollection = ThemeCollection(with: ThemeStyle.preferredStyle)

Expand Down
16 changes: 8 additions & 8 deletions ownCloud/Bookmarks/BookmarkViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ class BookmarkViewController: StaticTableViewController {
saveBarButtonItem.accessibilityIdentifier = "save-bar-button"

// Name section + row
nameRow = StaticTableViewRow(textFieldWithAction: { [weak self] (_, sender) in
if let textField = sender as? UITextField {
nameRow = StaticTableViewRow(textFieldWithAction: { [weak self] (_, sender, action) in
if let textField = sender as? UITextField, action == .changed {
self?.bookmark?.name = (textField.text?.count == 0) ? nil : textField.text
}
}, placeholder: "Name".localized, identifier: "row-name-name", accessibilityLabel: "Server name".localized)

nameSection = StaticTableViewSection(headerTitle: "Name".localized, footerTitle: nil, identifier: "section-name", rows: [ nameRow! ])

// URL section + row
urlRow = StaticTableViewRow(textFieldWithAction: { [weak self] (_, sender) in
if let textField = sender as? UITextField {
urlRow = StaticTableViewRow(textFieldWithAction: { [weak self] (_, sender, action) in
if let textField = sender as? UITextField, action == .changed {
var placeholderString = "Name".localized
var changedBookmark = false

Expand Down Expand Up @@ -161,15 +161,15 @@ class BookmarkViewController: StaticTableViewController {
urlSection = StaticTableViewSection(headerTitle: "Server URL".localized, footerTitle: nil, identifier: "section-url", rows: [ urlRow! ])

// Credentials section + rows
usernameRow = StaticTableViewRow(textFieldWithAction: { [weak self] (_, sender) in
if (sender as? UITextField) != nil, self?.bookmark?.authenticationData != nil {
usernameRow = StaticTableViewRow(textFieldWithAction: { [weak self] (_, sender, action) in
if (sender as? UITextField) != nil, self?.bookmark?.authenticationData != nil, action == .changed {
self?.bookmark?.authenticationData = nil
self?.composeSectionsAndRows(animated: true)
}
}, placeholder: "Username".localized, autocorrectionType: .no, identifier: "row-credentials-username", accessibilityLabel: "Server Username".localized)

passwordRow = StaticTableViewRow(secureTextFieldWithAction: { [weak self] (_, sender) in
if (sender as? UITextField) != nil, self?.bookmark?.authenticationData != nil {
passwordRow = StaticTableViewRow(secureTextFieldWithAction: { [weak self] (_, sender, action) in
if (sender as? UITextField) != nil, self?.bookmark?.authenticationData != nil, action == .changed {
self?.bookmark?.authenticationData = nil
self?.composeSectionsAndRows(animated: true)
}
Expand Down
187 changes: 179 additions & 8 deletions ownCloud/Client/Actions/Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,47 @@ class Action : NSObject {
}

// MARK: - Provide Card view controller
class func cardViewController(for item: OCItem, with context: ActionContext, progressHandler: ActionProgressHandler? = nil, completionHandler: ((Action, Error?) -> Void)? = nil) -> UIViewController {

class func cardViewController(for item: OCItem, with context: ActionContext, progressHandler: ActionProgressHandler? = nil, completionHandler: ((Action, Error?) -> Void)? = nil) -> UIViewController? {
guard let core = context.core else { return nil }

let tableViewController = MoreStaticTableViewController(style: .grouped)
let header = MoreViewHeader(for: item, with: context.core!)
let moreViewController = MoreViewController(item: item, core: context.core!, header: header, viewController: tableViewController)
let header = MoreViewHeader(for: item, with: core)
let moreViewController = MoreViewController(item: item, core: core, header: header, viewController: tableViewController)
hosy marked this conversation as resolved.
Show resolved Hide resolved

if core.connectionStatus == .online {
if core.connection.capabilities?.sharingAPIEnabled == 1 {
OnMainThread {
if item.isSharedWithUser || item.isShared {
let progressView = UIActivityIndicatorView(style: Theme.shared.activeCollection.activityIndicatorViewStyle)
progressView.startAnimating()

let row = StaticTableViewRow(rowWithAction: nil, title: "Searching Shares…".localized, alignment: .left, accessoryView: progressView, identifier: "share-searching")
let placeholderRow = StaticTableViewRow(rowWithAction: nil, title: "", alignment: .left, identifier: "share-empty-searching")
self.updateSharingSection(sectionIdentifier: "share-section", rows: [placeholderRow, row], tableViewController: tableViewController, contentViewController: moreViewController)

core.unifiedShares(for: item, completionHandler: { (shares) in
OnMainThread {
let shareRows = self.shareRows(shares: shares, item: item, presentingController: moreViewController, context: context)
self.updateSharingSection(sectionIdentifier: "share-section", rows: shareRows, tableViewController: tableViewController, contentViewController: moreViewController)
}
})
}
}
} else {
if let publicLinkRow = self.shareAsPublicLinkRow(item: item, presentingController: moreViewController, context: context) {
tableViewController.insertSection(StaticTableViewSection(headerTitle: nil, footerTitle: nil, identifier: "share-section", rows: [publicLinkRow]), at: 0, animated: false)
}
}
}
hosy marked this conversation as resolved.
Show resolved Hide resolved

let title = NSAttributedString(string: "Actions".localized, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 20, weight: .heavy)])

let actions = Action.sortedApplicableActions(for: context)

actions.forEach({
$0.actionWillRunHandler = {
moreViewController.dismiss(animated: true)
$0.actionWillRunHandler = { [weak moreViewController] in
moreViewController?.dismiss(animated: true)
}

$0.progressHandler = progressHandler
Expand Down Expand Up @@ -243,11 +271,13 @@ class Action : NSObject {
}

// MARK: - Action UI elements
private static let staticRowImageWidth : CGFloat = 32

func provideStaticRow() -> StaticTableViewRow? {
return StaticTableViewRow(buttonWithAction: { (_ row, _ sender) in
self.willRun()
self.run()
}, title: actionExtension.name, style: actionExtension.category == .destructive ? .destructive : .plain, identifier: actionExtension.identifier.rawValue)
}, title: actionExtension.name, style: actionExtension.category == .destructive ? .destructive : .plain, image: self.icon, imageWidth: Action.staticRowImageWidth, alignment: .left, identifier: actionExtension.identifier.rawValue)
}

func provideContextualAction() -> UIContextualAction? {
Expand All @@ -259,10 +289,20 @@ class Action : NSObject {
}

func provideAlertAction() -> UIAlertAction? {
return UIAlertAction(title: self.actionExtension.name, style: actionExtension.category == .destructive ? .destructive : .default, handler: { (_ alertAction) in
let alertAction = UIAlertAction(title: self.actionExtension.name, style: actionExtension.category == .destructive ? .destructive : .default, handler: { (_ alertAction) in
self.willRun()
self.run()
})

let image = self.icon
if alertAction.responds(to: NSSelectorFromString("setImage:")) {
alertAction.setValue(image, forKey: "image")
}
if alertAction.responds(to: NSSelectorFromString("_setTitleTextAlignment:")) {
alertAction.setValue(CATextLayerAlignmentMode.left, forKey: "titleTextAlignment")
}

return alertAction
}

// MARK: - Action metadata
Expand All @@ -272,7 +312,7 @@ class Action : NSObject {

var icon : UIImage? {
if let locationIdentifier = context.location?.identifier {
return Action.iconForLocation(locationIdentifier)
return type(of: self).iconForLocation(locationIdentifier)
}

return nil
Expand All @@ -281,4 +321,135 @@ class Action : NSObject {
var position : ActionPosition {
return type(of: self).applicablePosition(forContext: context)
}

}

// MARK: - Sharing

private extension Action {

class func shareRows(shares: [OCShare], item: OCItem, presentingController: UIViewController, context: ActionContext) -> [StaticTableViewRow] {
hosy marked this conversation as resolved.
Show resolved Hide resolved
var shareRows: [StaticTableViewRow] = []

var userTitle = ""
var linkTitle = ""
var hasUserGroupSharing = false
var hasLinkSharing = false

if item.isSharedWithUser {
// find shares by others
if let itemOwner = item.owner, itemOwner.isRemote, let ownerName = itemOwner.displayName ?? itemOwner.userName {
// - remote shares
userTitle = String(format: "Shared by %@".localized, ownerName)
hasUserGroupSharing = true
} else {
// - local shares
for share in shares {
if let ownerName = share.itemOwner?.displayName {
userTitle = String(format: "Shared by %@".localized, ownerName)
hasUserGroupSharing = true
break
}
}
}
} else {
// find Shares by me
let privateShares = shares.filter { (share) -> Bool in
return share.type != .link
}

if privateShares.count > 0 {
let title = ((privateShares.count > 1) ? "Recipients" : "Recipient").localized

userTitle = "\(privateShares.count) \(title)"
hasUserGroupSharing = true
}
}

// find Public link shares
let linkShares = shares.filter { (share) -> Bool in
return share.type == .link
}
if linkShares.count > 0 {
let title = ((linkShares.count > 1) ? "Links" : "Link").localized

linkTitle.append("\(linkShares.count) \(title)")
hasLinkSharing = true
}

if hasUserGroupSharing {
let addGroupRow = StaticTableViewRow(rowWithAction: { [weak presentingController, weak context] (_, _) in
if let context = context, let presentingController = presentingController, let core = context.core {
let sharingViewController = GroupSharingTableViewController(core: core, item: item)
sharingViewController.shares = shares

self.dismiss(presentingController: presentingController, andPresent: sharingViewController, on: context.viewController)
}
}, title: userTitle, subtitle: nil, image: UIImage(named: "group"), imageWidth: Action.staticRowImageWidth, alignment: .left, accessoryType: .disclosureIndicator)
shareRows.append(addGroupRow)
} else if item.isShareable {
shareRows.append(self.shareAsGroupRow(item: item, presentingController: presentingController, context: context))
}

if hasLinkSharing, let core = context.core, core.connection.capabilities?.publicSharingEnabled == true {
let addGroupRow = StaticTableViewRow(rowWithAction: { [weak presentingController, weak context] (_, _) in
if let context = context, let presentingController = presentingController {
let sharingViewController = PublicLinkTableViewController(core: core, item: item)
sharingViewController.shares = shares

self.dismiss(presentingController: presentingController, andPresent: sharingViewController, on: context.viewController)
}
}, title: linkTitle, subtitle: nil, image: UIImage(named: "link"), imageWidth: Action.staticRowImageWidth, alignment: .left, accessoryType: .disclosureIndicator)
shareRows.append(addGroupRow)
} else if let publicLinkRow = self.shareAsPublicLinkRow(item: item, presentingController: presentingController, context: context) {
shareRows.append(publicLinkRow)
}

return shareRows
}

private class func updateSharingSection(sectionIdentifier: String, rows: [StaticTableViewRow], tableViewController: MoreStaticTableViewController, contentViewController: MoreViewController) {
if let section = tableViewController.sectionForIdentifier(sectionIdentifier) {
tableViewController.removeSection(section)
}
if rows.count > 0 {
tableViewController.insertSection(MoreStaticTableViewSection(identifier: "share-section", rows: rows), at: 0, animated: false)
}
}

private class func shareAsGroupRow(item : OCItem, presentingController: UIViewController, context: ActionContext) -> StaticTableViewRow {
let title = ((item.type == .collection) ? "Share this folder" : "Share this file").localized

let addGroupRow = StaticTableViewRow(buttonWithAction: { [weak presentingController, weak context] (_, _) in
if let context = context, let presentingController = presentingController, let core = context.core {
self.dismiss(presentingController: presentingController,
andPresent: GroupSharingTableViewController(core: core, item: item),
on: context.viewController)
}
}, title: title, style: .plain, image: UIImage(named: "group"), imageWidth: Action.staticRowImageWidth, alignment: .left, identifier: "share-add-group")

return addGroupRow
}

private class func shareAsPublicLinkRow(item : OCItem, presentingController: UIViewController, context: ActionContext) -> StaticTableViewRow? {
let addGroupRow = StaticTableViewRow(buttonWithAction: { [weak presentingController, weak context] (_, _) in
if let context = context, let presentingController = presentingController, let core = context.core {
self.dismiss(presentingController: presentingController,
andPresent: PublicLinkTableViewController(core: core, item: item),
on: context.viewController)
}
}, title: "Links".localized, style: .plain, image: UIImage(named: "link"), imageWidth: Action.staticRowImageWidth, alignment: .left, identifier: "share-add-group")

return addGroupRow
}

private class func dismiss(presentingController: UIViewController, andPresent viewController: UIViewController, on hostViewController: UIViewController?) {
presentingController.dismiss(animated: true)

guard let hostViewController = hostViewController else { return }

let navigationController = ThemeNavigationController(rootViewController: viewController)

hostViewController.present(navigationController, animated: true, completion: nil)
}
}
22 changes: 9 additions & 13 deletions ownCloud/Client/Actions/Actions+Extensions/CopyAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ class CopyAction : Action {
override class var name : String? { return "Copy".localized }
override class var locations : [OCExtensionLocationIdentifier]? { return [.moreItem, .moreFolder, .toolbar] }

// MARK: - Extension matching
override class func applicablePosition(forContext: ActionContext) -> ActionPosition {
if forContext.items.contains(where: {$0.type == .file}),
let path = forContext.query?.queryPath, path.isRootPath,
let containsFolder = forContext.preferences?["containsFolders"] as? Bool, !containsFolder {
return .none
}
// Examine items in context
return .middle
}

// MARK: - Action implementation
override func run() {
guard context.items.count > 0, let viewController = context.viewController, let core = self.core else {
Expand All @@ -45,8 +34,7 @@ class CopyAction : Action {

let items = context.items

let directoryPickerViewController = ClientDirectoryPickerViewController(core: core, path: "/", selectButtonTitle: "Copy here", completion: { (selectedDirectory) in

let directoryPickerViewController = ClientDirectoryPickerViewController(core: core, path: "/", selectButtonTitle: "Copy here".localized, avoidConflictsWith: items, choiceHandler: { (selectedDirectory) in
if let targetDirectory = selectedDirectory {
items.forEach({ (item) in

Expand All @@ -68,4 +56,12 @@ class CopyAction : Action {
let pickerNavigationController = ThemeNavigationController(rootViewController: directoryPickerViewController)
viewController.present(pickerNavigationController, animated: true)
}

override class func iconForLocation(_ location: OCExtensionLocationIdentifier) -> UIImage? {
if location == .moreItem {
return UIImage(named: "copy-file")
}

return nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CreateFolderAction : Action {
}

override class func iconForLocation(_ location: OCExtensionLocationIdentifier) -> UIImage? {
if location == .toolbar {
if location == .toolbar || location == .plusButton {
return Theme.shared.image(for: "folder-create", size: CGSize(width: 30.0, height: 30.0))!.withRenderingMode(.alwaysTemplate)
}

Expand Down
19 changes: 18 additions & 1 deletion ownCloud/Client/Actions/Actions+Extensions/DeleteAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ class DeleteAction : Action {

// MARK: - Extension matching
override class func applicablePosition(forContext: ActionContext) -> ActionPosition {
// Examine items in context
let sharedWithUser = forContext.items.sharedWithUser

if let core = forContext.core {
for sharedItem in sharedWithUser {
if sharedItem.isShareRootItem(from: core) {
return .none
}
}
}

return .last
}

Expand Down Expand Up @@ -84,4 +93,12 @@ class DeleteAction : Action {
viewController.present(alertController, animated: true)

}

override class func iconForLocation(_ location: OCExtensionLocationIdentifier) -> UIImage? {
if location == .moreItem {
return UIImage(named: "trash")
}

return nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class DuplicateAction : Action {
override class var category : ActionCategory? { return .normal }
override class var name : String? { return "Duplicate".localized }
override class var locations : [OCExtensionLocationIdentifier]? { return [.moreItem, .moreFolder, .toolbar] }
var remainingItems : [OCItem] = []

// MARK: - Extension matching
override class func applicablePosition(forContext: ActionContext) -> ActionPosition {
Expand Down Expand Up @@ -106,4 +105,12 @@ class DuplicateAction : Action {

self.completed()
}

override class func iconForLocation(_ location: OCExtensionLocationIdentifier) -> UIImage? {
if location == .moreItem {
return UIImage(named: "duplicate-file")
}

return nil
}
}
Loading