Skip to content

Commit

Permalink
Copy action (#207)
Browse files Browse the repository at this point in the history
* - Made the Copy action.
- Fix some UI Color scheme inconsistencies.

* - Made the 'Copy here'  button respect the original title

* - SDK Update

* - Fix for a lint warning
  • Loading branch information
pablocarmu authored and mneuwert committed Jan 31, 2019
1 parent 8e0776b commit 330f7be
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ios-sdk
Submodule ios-sdk updated 31 files
+2 −2 .tx/config
+0 −70 ownCloudSDK.xcodeproj/project.pbxproj
+0 −203 ownCloudSDK/Resources/cs.lproj/Localizable.strings
+0 −203 ownCloudSDK/Resources/de-DE.lproj/Localizable.strings
+ ownCloudSDK/Resources/en-GB.lproj/Localizable.strings
+ ownCloudSDK/Resources/en_GB.lproj/Localizable.strings
+0 −203 ownCloudSDK/Resources/ko.lproj/Localizable.strings
+0 −203 ownCloudSDK/Resources/mk.lproj/Localizable.strings
+0 −203 ownCloudSDK/Resources/nb-NO.lproj/Localizable.strings
+0 −203 ownCloudSDK/Resources/nn-NO.lproj/Localizable.strings
+ ownCloudSDK/Resources/pt-BR.lproj/Localizable.strings
+ ownCloudSDK/Resources/pt_BR.lproj/Localizable.strings
+ ownCloudSDK/Resources/pt_PT.lproj/Localizable.strings
+ ownCloudSDK/Resources/ru.lproj/Localizable.strings
+ ownCloudSDK/Resources/sq.lproj/Localizable.strings
+ ownCloudSDK/Resources/th-TH.lproj/Localizable.strings
+ ownCloudSDK/Resources/th_TH.lproj/Localizable.strings
+ ownCloudSDK/Resources/zh_CN.lproj/Localizable.strings
+0 −46 ownCloudUI/Resources/cs.lproj/Localizable.strings
+0 −46 ownCloudUI/Resources/de-DE.lproj/Localizable.strings
+0 −46 ownCloudUI/Resources/de.lproj/Localizable.strings
+ ownCloudUI/Resources/en_GB.lproj/Localizable.strings
+ ownCloudUI/Resources/gl.lproj/Localizable.strings
+0 −46 ownCloudUI/Resources/ko.lproj/Localizable.strings
+0 −46 ownCloudUI/Resources/mk.lproj/Localizable.strings
+0 −46 ownCloudUI/Resources/nb-NO.lproj/Localizable.strings
+0 −46 ownCloudUI/Resources/nn-NO.lproj/Localizable.strings
+ ownCloudUI/Resources/pt_BR.lproj/Localizable.strings
+ ownCloudUI/Resources/pt_PT.lproj/Localizable.strings
+ ownCloudUI/Resources/th_TH.lproj/Localizable.strings
+0 −46 ownCloudUI/Resources/zh-Hans.lproj/Localizable.strings
4 changes: 4 additions & 0 deletions ownCloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
6E586D002199A78E00F680C4 /* DeleteAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E586CFF2199A78E00F680C4 /* DeleteAction.swift */; };
6E83C77E20A32C1B0066EC23 /* SettingsSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E83C77D20A32C1B0066EC23 /* SettingsSection.swift */; };
6E83C78420A33C180066EC23 /* LAContext+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E83C78320A33C180066EC23 /* LAContext+Extension.swift */; };
6E91F37E21ECA6FD009436D2 /* CopyAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E91F37D21ECA6FD009436D2 /* CopyAction.swift */; };
6EA78B8F2179B55400A5216A /* ImageScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EA78B8E2179B55400A5216A /* ImageScrollView.swift */; };
6EADE9372192E235006821B3 /* UIImagePickerController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EADE9362192E235006821B3 /* UIImagePickerController+Extension.swift */; };
6EB8EDC52114358400C2BF44 /* folder-create.tvg in Resources */ = {isa = PBXBuildFile; fileRef = 6EB8EDBE2114358300C2BF44 /* folder-create.tvg */; };
Expand Down Expand Up @@ -483,6 +484,7 @@
6E586CFF2199A78E00F680C4 /* DeleteAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteAction.swift; sourceTree = "<group>"; };
6E83C77D20A32C1B0066EC23 /* SettingsSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsSection.swift; sourceTree = "<group>"; };
6E83C78320A33C180066EC23 /* LAContext+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LAContext+Extension.swift"; sourceTree = "<group>"; };
6E91F37D21ECA6FD009436D2 /* CopyAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopyAction.swift; sourceTree = "<group>"; };
6EA78B8E2179B55400A5216A /* ImageScrollView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageScrollView.swift; sourceTree = "<group>"; };
6EADE9362192E235006821B3 /* UIImagePickerController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImagePickerController+Extension.swift"; sourceTree = "<group>"; };
6EB8EDBE2114358300C2BF44 /* folder-create.tvg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "folder-create.tvg"; path = "img/filetypes-tvg/folder-create.tvg"; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -876,6 +878,7 @@
6E3A103D219D5BBA00F90C96 /* RenameAction.swift */,
6E3A104C219D6F0100F90C96 /* DuplicateAction.swift */,
6ED1B80A21A4004900E16C95 /* CreateFolderAction.swift */,
6E91F37D21ECA6FD009436D2 /* CopyAction.swift */,
);
path = "Actions+Extensions";
sourceTree = "<group>";
Expand Down Expand Up @@ -1684,6 +1687,7 @@
23957A6D209AFFE8003C8537 /* MoreSettingsSection.swift in Sources */,
4C464BEF2187AF1500D30602 /* PDFThumbnailCollectionViewCell.swift in Sources */,
232B01F62126B10900366FA0 /* MoreStaticTableViewController.swift in Sources */,
6E91F37E21ECA6FD009436D2 /* CopyAction.swift in Sources */,
593BAB97209F8A0500023634 /* AppLockManager.swift in Sources */,
DC85493421831B0B00782BA8 /* Tools.swift in Sources */,
DCFED972208095E200A2D984 /* ClientItemCell.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions ownCloud/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
OCExtensionManager.shared.addExtension(RenameAction.actionExtension)
OCExtensionManager.shared.addExtension(DuplicateAction.actionExtension)
OCExtensionManager.shared.addExtension(CreateFolderAction.actionExtension)
OCExtensionManager.shared.addExtension(CopyAction.actionExtension)

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

Expand Down
62 changes: 62 additions & 0 deletions ownCloud/Client/Actions/Actions+Extensions/CopyAction.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// CopyAction.swift
// ownCloud
//
// Created by Pablo Carrascal on 14/01/2019.
// Copyright © 2019 ownCloud GmbH. All rights reserved.
//

/*
* Copyright (C) 2018, ownCloud GmbH.
*
* This code is covered by the GNU Public License Version 3.
*
* For distribution utilizing Apple mechanisms please see https://owncloud.org/contribute/iOS-license-exception/
* You should have received a copy of this license along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.en.html>.
*
*/

import Foundation
import ownCloudSDK

class CopyAction : Action {
override class var identifier : OCExtensionIdentifier? { return OCExtensionIdentifier("com.owncloud.action.copy") }
override class var category : ActionCategory? { return .normal }
override class var name : String? { return "Copy".localized }
override class var locations : [OCExtensionLocationIdentifier]? { return [.moreItem, .moreFolder] }

// MARK: - Extension matching
override class func applicablePosition(forContext: ActionContext) -> ActionPosition {
// 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 {
completionHandler?(NSError(ocError: .insufficientParameters))
return
}

let items = context.items

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

if let progress = self.core?.copy(item, to: selectedDirectory!, withName: item.name!, options: nil, resultHandler: { (error, _, _, _) in
if error != nil {
self.completed(with: error)
} else {
self.completed()
}

}) {
self.publish(progress: progress)
}
})
})

let pickerNavigationController = ThemeNavigationController(rootViewController: directoryPickerViewController)
viewController.present(pickerNavigationController, animated: true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,12 @@ class ClientDirectoryPickerViewController: ClientQueryViewController {
super.init(core: inCore, query: OCQuery(forPath: path))

self.query.addFilter(ClientDirectoryPickerViewController.directoryFilter, withIdentifier: ClientDirectoryPickerViewController.DIRECTORY_FILTER_IDENTIFIER)

Theme.shared.register(client: self)
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

deinit {
Theme.shared.unregister(client: self)
}

// MARK: - ViewController lifecycle
override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -91,7 +85,7 @@ class ClientDirectoryPickerViewController: ClientQueryViewController {
return
}

self.navigationController?.pushViewController(ClientDirectoryPickerViewController(core: core, path: path, completion: completion), animated: true)
self.navigationController?.pushViewController(ClientDirectoryPickerViewController(core: core, path: path, selectButtonTitle: selectButtonTitle, completion: completion), animated: true)
}

override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
Expand Down
2 changes: 1 addition & 1 deletion ownCloud/Client/ClientQueryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class ClientQueryViewController: UITableViewController, Themeable {

switch query.state {
case .idle:
OnMainThread{
OnMainThread {
if !self.refreshController!.isRefreshing {
self.refreshController?.beginRefreshing()
}
Expand Down
2 changes: 2 additions & 0 deletions ownCloud/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@
"Duplicate" = "Duplicate";
"Move" = "Move";
"Open in" = "Open in";
"Copy" = "Copy";
"Copy here" = "Copy here";

/* Directory Picker Messages */
"Move here" = "Move here";
Expand Down
1 change: 1 addition & 0 deletions ownCloud/Theming/NSObject+ThemeApplication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ extension NSObject {
navigationBar.backgroundColor = collection.navigationBarColors.backgroundColor
navigationBar.tintColor = collection.navigationBarColors.tintColor
navigationBar.titleTextAttributes = [ .foregroundColor : collection.navigationBarColors.labelColor ]
navigationBar.isTranslucent = false
}

if self.isKind(of: UIToolbar.self) {
Expand Down

0 comments on commit 330f7be

Please sign in to comment.