Skip to content

Commit

Permalink
- regrouping shortcut actions into their own folder
Browse files Browse the repository at this point in the history
- CreateShortcutFileAction: break out creation functionality into its own view controller
- CreateShortcutFileViewController:
	- dedicated view controller for creating shortcuts
	- allows picking files and folders for shortcuts to point to and presents an embedded preview for them
	- improved error handling
- INIFile: fix formatting bug that could accidentally leak memory into the .url file
- ClientLocationPicker: add ability to allow picking files via new .allowFileSelection property
  • Loading branch information
felix-schwarz committed Apr 17, 2024
1 parent 41ea6d4 commit fad824b
Show file tree
Hide file tree
Showing 11 changed files with 397 additions and 136 deletions.
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ disabled_rules:
- function_parameter_count
- comment_spacing
- unused_closure_parameter
- control_statement
- nesting
- comma
custom_rules:
Expand Down
16 changes: 14 additions & 2 deletions ownCloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@
DCB7967F2BC83E6E00D6D759 /* text-uri-list.tvg in Resources */ = {isa = PBXBuildFile; fileRef = DCB7967E2BC83E6E00D6D759 /* text-uri-list.tvg */; };
DCB7969D2BCE71C300D6D759 /* OpenShortcutFileAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCB7969C2BCE71C300D6D759 /* OpenShortcutFileAction.swift */; };
DCB7969F2BCE745500D6D759 /* INIFile+ShortcutResolution.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCB7969E2BCE745500D6D759 /* INIFile+ShortcutResolution.swift */; };
DCB796A72BCFB6EC00D6D759 /* CreateShortcutFileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCB796A62BCFB6EC00D6D759 /* CreateShortcutFileViewController.swift */; };
DCBAEADB29A3674700BFF393 /* OCItemPolicy+UniversalItemListCellContentProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCBAEAD429A361C100BFF393 /* OCItemPolicy+UniversalItemListCellContentProvider.swift */; };
DCBAEADE29A5536F00BFF393 /* CollectionViewSupplementaryCellProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCBAEADD29A5536F00BFF393 /* CollectionViewSupplementaryCellProvider.swift */; };
DCBAEAE029A554CC00BFF393 /* CollectionViewSupplementaryItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCBAEADF29A554CC00BFF393 /* CollectionViewSupplementaryItem.swift */; };
Expand Down Expand Up @@ -1565,6 +1566,7 @@
DCB7967E2BC83E6E00D6D759 /* text-uri-list.tvg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "text-uri-list.tvg"; path = "img/filetypes-tvg/text-uri-list.tvg"; sourceTree = SOURCE_ROOT; };
DCB7969C2BCE71C300D6D759 /* OpenShortcutFileAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenShortcutFileAction.swift; sourceTree = "<group>"; };
DCB7969E2BCE745500D6D759 /* INIFile+ShortcutResolution.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "INIFile+ShortcutResolution.swift"; sourceTree = "<group>"; };
DCB796A62BCFB6EC00D6D759 /* CreateShortcutFileViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateShortcutFileViewController.swift; sourceTree = "<group>"; };
DCBAEAD429A361C100BFF393 /* OCItemPolicy+UniversalItemListCellContentProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCItemPolicy+UniversalItemListCellContentProvider.swift"; sourceTree = "<group>"; };
DCBAEADD29A5536F00BFF393 /* CollectionViewSupplementaryCellProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewSupplementaryCellProvider.swift; sourceTree = "<group>"; };
DCBAEADF29A554CC00BFF393 /* CollectionViewSupplementaryItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewSupplementaryItem.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1956,6 +1958,7 @@
children = (
DCE4E43D24C19C3E0051722F /* Action+UserInterface.swift */,
DC255E432319AD13007279B1 /* Scanner */,
DCB796A52BCFB5DA00D6D759 /* Shortcuts */,
6E586CF52199A70100F680C4 /* Actions+Extensions */,
39CD755323D8392D00193950 /* EditDocumentViewController.swift */,
025F063924AA18C7009D8FC5 /* ImageMetadataViewController.swift */,
Expand Down Expand Up @@ -2287,8 +2290,6 @@
DC0CE19C28C89CD9009ABDFB /* CreateDocumentAction.swift */,
DC1621372B8FE9BF00EB17F8 /* AddToSidebarAction.swift */,
DCB796572BC535AD00D6D759 /* RemoveFromSidebarAction.swift */,
DCB796632BC73AF100D6D759 /* CreateShortcutFileAction.swift */,
DCB7969C2BCE71C300D6D759 /* OpenShortcutFileAction.swift */,
);
path = "Actions+Extensions";
sourceTree = "<group>";
Expand Down Expand Up @@ -3160,6 +3161,16 @@
path = "Shortcut Files";
sourceTree = "<group>";
};
DCB796A52BCFB5DA00D6D759 /* Shortcuts */ = {
isa = PBXGroup;
children = (
DCB796632BC73AF100D6D759 /* CreateShortcutFileAction.swift */,
DCB796A62BCFB6EC00D6D759 /* CreateShortcutFileViewController.swift */,
DCB7969C2BCE71C300D6D759 /* OpenShortcutFileAction.swift */,
);
path = Shortcuts;
sourceTree = "<group>";
};
DCBAEADC29A552D100BFF393 /* Supplementary Cells */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4667,6 +4678,7 @@
4CC46D212284C677009E938F /* BookmarkInfoViewController.swift in Sources */,
DCB6B1F5292CC46B00D27573 /* AccountController+ItemActions.swift in Sources */,
6E5FC172221590B000F60846 /* DisplayHostViewController.swift in Sources */,
DCB796A72BCFB6EC00D6D759 /* CreateShortcutFileViewController.swift in Sources */,
4C51727F22DE04BD001BC97F /* ScheduledTaskManager.swift in Sources */,
DCB796492BC4854800D6D759 /* INIFile.swift in Sources */,
39BC9C3023DB831F0097C52D /* DocumentEditingAction.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = "en"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down

This file was deleted.

62 changes: 62 additions & 0 deletions ownCloud/Client/Actions/Shortcuts/CreateShortcutFileAction.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// CreateShortcutFileAction.swift
// ownCloud
//
// Created by Felix Schwarz on 10.04.24.
// Copyright © 2024 ownCloud GmbH. All rights reserved.
//

/*
* Copyright (C) 2024, 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 UIKit
import ownCloudSDK
import ownCloudAppShared

class CreateShortcutFileAction: Action {
override open class var identifier : OCExtensionIdentifier? { return OCExtensionIdentifier("com.owncloud.action.createShortcutFile") }
override open class var category : ActionCategory? { return .normal }
override open class var name : String? { return "Create shortcut".localized }
override open class var locations : [OCExtensionLocationIdentifier]? { return [.folderAction, .emptyFolder] }

// MARK: - Extension matching
override open class func applicablePosition(forContext: ActionContext) -> ActionPosition {
if forContext.items.count > 1 {
return .none
}

if forContext.items.first?.type != .collection {
return .none
}

if forContext.items.first?.permissions.contains(.createFile) == false {
return .none
}

return .middle
}

// MARK: - Action implementation
override func run() {
guard context.items.count > 0, let parentItem = context.items.first, let clientContext = context.clientContext else {
completed(with: NSError(ocError: .itemNotFound))
return
}

let navigationController = ThemeNavigationController(rootViewController: CreateShortcutFileViewController(parentItem: parentItem, clientContext: clientContext))
clientContext.present(navigationController, animated: true)

self.completed()
}

override open class func iconForLocation(_ location: OCExtensionLocationIdentifier) -> UIImage? {
return UIImage(systemName: "arrow.up.forward.square")?.withRenderingMode(.alwaysTemplate)
}
}
Loading

0 comments on commit fad824b

Please sign in to comment.