From 286f1d74776b4d45cd498681a949cdc66df4e941 Mon Sep 17 00:00:00 2001 From: Pablo Carrascal Date: Tue, 21 Aug 2018 10:27:06 +0200 Subject: [PATCH] - SDK Updated to file management branch to be able to use progress. - Coded the rename feature using the more view. --- ios-sdk | 2 +- ownCloud.xcodeproj/project.pbxproj | 1 - .../Bookmarks/BookmarkViewController.swift | 4 +- .../Client/ClientQueryViewController.swift | 41 +++++++++++++++---- .../CardPresentationController.swift | 2 +- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/ios-sdk b/ios-sdk index c2091be41..a1e5ca01d 160000 --- a/ios-sdk +++ b/ios-sdk @@ -1 +1 @@ -Subproject commit c2091be4110d943492b28dcd025459272e1382a1 +Subproject commit a1e5ca01d6fea271cc7db85e78221db056f604c9 diff --git a/ownCloud.xcodeproj/project.pbxproj b/ownCloud.xcodeproj/project.pbxproj index b3ec58ff5..6f203b2df 100644 --- a/ownCloud.xcodeproj/project.pbxproj +++ b/ownCloud.xcodeproj/project.pbxproj @@ -1224,7 +1224,6 @@ 593BAB97209F8A0500023634 /* AppLockManager.swift in Sources */, DCFED972208095E200A2D984 /* ClientItemCell.swift in Sources */, 23E22BB720C6A5C40024D11E /* UIDevice+UIUserInterfaceIdiom.swift in Sources */, - 6E216A642112F58700ED21BD /* NamingViewController.swift in Sources */, 23F6238120B587EF004FDE8B /* SortMethod.swift in Sources */, 239F1319205A693A0029F186 /* UIColor+Extension.swift in Sources */, DC3BE0E12077CD4B002A0AC0 /* Synchronized.swift in Sources */, diff --git a/ownCloud/Bookmarks/BookmarkViewController.swift b/ownCloud/Bookmarks/BookmarkViewController.swift index 51b15b01d..5a5b4d0bb 100644 --- a/ownCloud/Bookmarks/BookmarkViewController.swift +++ b/ownCloud/Bookmarks/BookmarkViewController.swift @@ -497,7 +497,7 @@ class BookmarkViewController: StaticTableViewController { removeRows.append(tokenInfoRow!) } - if !authenticationMethodClass.usesUserName() { + if !authenticationMethodClass.usesUserName { removeRows.append(usernameRow!) } @@ -530,7 +530,7 @@ class BookmarkViewController: StaticTableViewController { credentialsSection?.insert(row: passwordRow!, at: 0, animated: animated) } - if authenticationMethodClass.usesUserName() { + if authenticationMethodClass.usesUserName { if usernameRow?.attached == false { credentialsSection?.insert(row: usernameRow!, at: 0, animated: animated) } diff --git a/ownCloud/Client/ClientQueryViewController.swift b/ownCloud/Client/ClientQueryViewController.swift index c2221068f..6edaa307e 100644 --- a/ownCloud/Client/ClientQueryViewController.swift +++ b/ownCloud/Client/ClientQueryViewController.swift @@ -560,12 +560,15 @@ extension ClientQueryViewController : SortBarDelegate { print("LOG ---> right button pressed") } - func sortBar(_ sortBar: SortBar, didUpdateSortMethod: SortMethod) { sortMethod = didUpdateSortMethod query?.sortComparator = sortMethod.comparator() } + + func sortBar(_ sortBar: SortBar, presentViewController: UIViewController, animated: Bool, completionHandler: (() -> Void)?) { + self.present(presentViewController, animated: animated, completion: completionHandler) + } } // MARK: - UISearchResultsUpdating Delegate @@ -595,11 +598,6 @@ extension ClientQueryViewController: UISearchResultsUpdating { } } } - - func sortBar(_ sortBar: SortBar, presentViewController: UIViewController, animated: Bool, completionHandler: (() -> Void)?) { - - self.present(presentViewController, animated: animated, completion: completionHandler) - } } // MARK: - ClientItemCell Delegate @@ -644,7 +642,36 @@ extension ClientQueryViewController: ClientItemCellDelegate { }, attributedTitle: delete, alignment: .center) - let renameRow: StaticTableViewRow = StaticTableViewRow(rowWithAction: nil, attributedTitle: rename, alignment: .center) + let renameRow: StaticTableViewRow = StaticTableViewRow(rowWithAction: { [weak self] (_, _) in + + moreVC.dismiss(animated: true, completion: { + let renamevc = NamingViewController(with: item, core: self?.core, stringValidator: { name in + if name.contains("/") || name.contains("\\") { + return (false, "File name cannot contain / or \\") + } else { + return (true, nil) + } + }, completion: { newName, _ in + + guard newName != nil else { + return + } + + if let progress = self?.core?.renameItem(item, to: newName, options: nil, resultHandler: { (error, _, _, _) in + if error != nil { + Log.log("Error \(String(describing: error)) renaming \(String(describing: item.path))") + } + }) { + self?.progressSummarizer?.startTracking(progress: progress) + } + }) + + let renameNavigationVC = ThemeNavigationController(rootViewController: renamevc) + renameNavigationVC.modalPresentationStyle = .overFullScreen + self?.navigationController?.present(renameNavigationVC, animated: true) + }) + }, attributedTitle: rename, alignment: .center) + tableViewController.addSection(StaticTableViewSection(headerAttributedTitle: title, identifier: "actions-section", rows: [ renameRow, deleteRow diff --git a/ownCloud/UI Elements/Card Presentation Controller/CardPresentationController.swift b/ownCloud/UI Elements/Card Presentation Controller/CardPresentationController.swift index a470cb3d9..18ffa85b3 100644 --- a/ownCloud/UI Elements/Card Presentation Controller/CardPresentationController.swift +++ b/ownCloud/UI Elements/Card Presentation Controller/CardPresentationController.swift @@ -66,7 +66,7 @@ final class CardPresentationController: UIPresentationController { let presentedFrame = CGRect(origin: presentedOrigin, size: presentedSize) return presentedFrame } - + // MARK: - Presentation override func presentationTransitionWillBegin() { if let containerView = containerView {