Skip to content

Commit

Permalink
- update SDK
Browse files Browse the repository at this point in the history
- ShareExtensionViewController: auto-open first account if only one account has been created
- OCSidebarItem: new class encapsulating custom user sidebar items, conforming to OCDataItem and OCDataItemVersioning
- OCVault+SidebarItems: add user side bar item management
- AccountController:
	- add saved searches and user sidebar items to configuration
	- add user sidebar items integration
- BrowserNavigationBookmark+AccountController: add support for sidebar items, refine representationSideBarItemRefs to return more (fallback) references
- Action: fix comment an identifier typos
- CollectionViewController:
	- add new method for retrieving the most specific client context for an index path
	- use new method to provide correct client context for allowDropOperation and performDropOperation
- OCLocation+Interactions: add new method for customized access to .openItem()
- OCSidebarItem+Cell: adds a cell provider for custom user sidebar items
- OCSidebarItem+Interactions: selection, swipe, context menu, drop and navigation restore support for OCSidebarItems
- BrowserNavigationBookmark: add sidebarItem property, including archiving/unarchiving
  • Loading branch information
felix-schwarz committed Feb 29, 2024
1 parent 2a4d536 commit 11076a6
Show file tree
Hide file tree
Showing 19 changed files with 676 additions and 14 deletions.
7 changes: 7 additions & 0 deletions ownCloud Share Extension/ShareExtensionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,13 @@ class ShareExtensionViewController: EmbeddingViewController, Themeable {
// Show location picker
showLocationPicker()
}

// Log in to first account if there's only one
let bookmarks = OCBookmarkManager.shared.bookmarks

if bookmarks.count == 1, let onlyBookmark = bookmarks.first {
AccountConnectionPool.shared.connection(for: onlyBookmark)?.connect()
}
}
}

Expand Down
44 changes: 44 additions & 0 deletions ownCloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@
DC0A35A124C1091400FB58FC /* UserInterfaceContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC0A35A024C1091400FB58FC /* UserInterfaceContext.swift */; };
DC0A5C432550C70800E6674B /* class-settings-sdk in Resources */ = {isa = PBXBuildFile; fileRef = DC0A5C422550C70800E6674B /* class-settings-sdk */; };
DC0CE19D28C89CD9009ABDFB /* CreateDocumentAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC0CE19C28C89CD9009ABDFB /* CreateDocumentAction.swift */; };
DC1621352B8FE26200EB17F8 /* OCVault+SidebarItems.h in Headers */ = {isa = PBXBuildFile; fileRef = DC1621332B8FE26200EB17F8 /* OCVault+SidebarItems.h */; settings = {ATTRIBUTES = (Public, ); }; };
DC1621362B8FE26200EB17F8 /* OCVault+SidebarItems.m in Sources */ = {isa = PBXBuildFile; fileRef = DC1621342B8FE26200EB17F8 /* OCVault+SidebarItems.m */; };
DC1621382B8FE9BF00EB17F8 /* AddToSidebarAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC1621372B8FE9BF00EB17F8 /* AddToSidebarAction.swift */; };
DC16213A2B8FEEE500EB17F8 /* OCSidebarItem+Cell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC1621392B8FEEE500EB17F8 /* OCSidebarItem+Cell.swift */; };
DC16213E2B8FF06800EB17F8 /* OCSidebarItem+Interactions.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC16213D2B8FF06800EB17F8 /* OCSidebarItem+Interactions.swift */; };
DC18898E218A773700CFB3F9 /* ownCloudMocking.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC0196A620F754CA00C41B78 /* ownCloudMocking.framework */; };
DC1B270C209CF34B004715E1 /* BookmarkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC1B270B209CF34B004715E1 /* BookmarkViewController.swift */; };
DC20DE6A21C01B210096000B /* ownCloudSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 239369782076110900BCE21A /* ownCloudSDK.framework */; };
Expand Down Expand Up @@ -369,6 +374,8 @@
DC7C101124B5FA7700227085 /* OCBookmark+AppExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = DC7C100E24B5F81E00227085 /* OCBookmark+AppExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
DC7C101224B5FD6500227085 /* OCBookmark+AppExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = DC7C100F24B5F81E00227085 /* OCBookmark+AppExtensions.m */; };
DC7DBA37207F84BF00E7337D /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC7DBA36207F84BF00E7337D /* main.swift */; };
DC8087992B8FDFD900AB1C45 /* OCSidebarItem.h in Headers */ = {isa = PBXBuildFile; fileRef = DC8087972B8FDFD900AB1C45 /* OCSidebarItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
DC80879A2B8FDFD900AB1C45 /* OCSidebarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = DC8087982B8FDFD900AB1C45 /* OCSidebarItem.m */; };
DC815C3F2A65D9CB00BFF393 /* AvailableOfflineAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC815C3E2A65D9CB00BFF393 /* AvailableOfflineAction.swift */; };
DC825E352A05083C00BFF393 /* GitInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC825E342A05083C00BFF393 /* GitInfo.swift */; };
DC82663C28168D2800F91F7D /* ClientContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC82663B28168D2800F91F7D /* ClientContext.swift */; };
Expand Down Expand Up @@ -1260,6 +1267,11 @@
DC0CE19128C7DBE3009ABDFB /* OpenInWebAppAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenInWebAppAction.swift; sourceTree = "<group>"; };
DC0CE19C28C89CD9009ABDFB /* CreateDocumentAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateDocumentAction.swift; sourceTree = "<group>"; };
DC136581208223F000FC0F60 /* OCBookmark+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCBookmark+Extension.swift"; sourceTree = "<group>"; };
DC1621332B8FE26200EB17F8 /* OCVault+SidebarItems.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OCVault+SidebarItems.h"; sourceTree = "<group>"; };
DC1621342B8FE26200EB17F8 /* OCVault+SidebarItems.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "OCVault+SidebarItems.m"; sourceTree = "<group>"; };
DC1621372B8FE9BF00EB17F8 /* AddToSidebarAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddToSidebarAction.swift; sourceTree = "<group>"; };
DC1621392B8FEEE500EB17F8 /* OCSidebarItem+Cell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCSidebarItem+Cell.swift"; sourceTree = "<group>"; };
DC16213D2B8FF06800EB17F8 /* OCSidebarItem+Interactions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OCSidebarItem+Interactions.swift"; sourceTree = "<group>"; };
DC1AC7CF2319ADAE002B7892 /* ScanViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanViewController.swift; sourceTree = "<group>"; };
DC1B270B209CF34B004715E1 /* BookmarkViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkViewController.swift; sourceTree = "<group>"; };
DC2218C42822C5B900808BCE /* OCVFSNode+FileProviderItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OCVFSNode+FileProviderItem.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1428,6 +1440,8 @@
DC7DBA36207F84BF00E7337D /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
DC7DBA52207F8BD600E7337D /* img */ = {isa = PBXFileReference; lastKnownFileType = folder; path = img; sourceTree = SOURCE_ROOT; };
DC7DBA53207FA80C00E7337D /* TVGImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TVGImage.swift; sourceTree = "<group>"; };
DC8087972B8FDFD900AB1C45 /* OCSidebarItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OCSidebarItem.h; sourceTree = "<group>"; };
DC8087982B8FDFD900AB1C45 /* OCSidebarItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OCSidebarItem.m; sourceTree = "<group>"; };
DC815C3E2A65D9CB00BFF393 /* AvailableOfflineAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvailableOfflineAction.swift; sourceTree = "<group>"; };
DC825E342A05083C00BFF393 /* GitInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GitInfo.swift; sourceTree = "<group>"; };
DC82663B28168D2800F91F7D /* ClientContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientContext.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1984,6 +1998,7 @@
DCB5D5692861BE9A004AF425 /* Search */,
DCA2EDDB279B0E5D001F04E6 /* Resource Sources */,
DCE4E43424C199860051722F /* Actions */,
DC16213C2B8FF02500EB17F8 /* Sidebar Items */,
399EA6ED25E6544000B6FF11 /* Sharing */,
DCE4E42F24C1963F0051722F /* User Interface */,
);
Expand Down Expand Up @@ -2249,6 +2264,7 @@
025F063224AA163C009D8FC5 /* DisplayExifMetadataAction.swift */,
39EF06AF25D6C3FC001E1E19 /* PresentationModeAction.swift */,
DC0CE19C28C89CD9009ABDFB /* CreateDocumentAction.swift */,
DC1621372B8FE9BF00EB17F8 /* AddToSidebarAction.swift */,
);
path = "Actions+Extensions";
sourceTree = "<group>";
Expand Down Expand Up @@ -2374,6 +2390,15 @@
path = "Cursor Support";
sourceTree = "<group>";
};
DC16213C2B8FF02500EB17F8 /* Sidebar Items */ = {
isa = PBXGroup;
children = (
DC1621392B8FEEE500EB17F8 /* OCSidebarItem+Cell.swift */,
DC16213D2B8FF06800EB17F8 /* OCSidebarItem+Interactions.swift */,
);
path = "Sidebar Items";
sourceTree = "<group>";
};
DC2323DA2AA7B5A100BFF393 /* Composer */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -2810,6 +2835,17 @@
path = tools;
sourceTree = "<group>";
};
DC8087962B8FDFB600AB1C45 /* Sidebar Items */ = {
isa = PBXGroup;
children = (
DC8087982B8FDFD900AB1C45 /* OCSidebarItem.m */,
DC8087972B8FDFD900AB1C45 /* OCSidebarItem.h */,
DC1621342B8FE26200EB17F8 /* OCVault+SidebarItems.m */,
DC1621332B8FE26200EB17F8 /* OCVault+SidebarItems.h */,
);
path = "Sidebar Items";
sourceTree = "<group>";
};
DC82664028168DAA00F91F7D /* Context */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3148,6 +3184,7 @@
DCF575E52796CBB3003BEBBA /* View Providers */,
DC774E5422F44DF6000B11A1 /* SDK Extensions */,
DC2A128828D076750088A2B7 /* Search */,
DC8087962B8FDFB600AB1C45 /* Sidebar Items */,
DC0030BE2350B1CE00BB8570 /* Tools */,
DCEA7F38282D3ACA0050A3C0 /* VFS */,
DC3DDEFE287E1AA500E5586D /* UIKit Extensions */,
Expand Down Expand Up @@ -3777,6 +3814,8 @@
DCC0856E2293F1FD008CC05C /* ownCloudApp.h in Headers */,
DCF2DA8124C836240026D790 /* OCBookmark+FPServices.h in Headers */,
DC66F3A523965A1400CF4812 /* NSDate+RFC3339.h in Headers */,
DC1621352B8FE26200EB17F8 /* OCVault+SidebarItems.h in Headers */,
DC8087992B8FDFD900AB1C45 /* OCSidebarItem.h in Headers */,
DC0030C22350B1CE00BB8570 /* NSData+Encoding.h in Headers */,
DCEA7F41282D3B110050A3C0 /* VFSManager.h in Headers */,
DCCD77792604C91600098573 /* NSDate+ComputedTimes.h in Headers */,
Expand Down Expand Up @@ -4583,6 +4622,7 @@
DCC085512293ED52008CC05C /* DisplaySettingsSection.swift in Sources */,
23EC77582137F3DD0032D4E6 /* PDFViewerViewController.swift in Sources */,
DCC8535823CE1236007BA3EB /* LicenseInAppProductListViewController.swift in Sources */,
DC1621382B8FE9BF00EB17F8 /* AddToSidebarAction.swift in Sources */,
23EC775B2137F3DD0032D4E6 /* OCExtensionType+Extension.swift in Sources */,
DC3F4522271A23A000ED2383 /* AcknowledgementsTableViewController.swift in Sources */,
4C88041822E78D790016CBA9 /* MediaFilesSettings.swift in Sources */,
Expand Down Expand Up @@ -4668,6 +4708,7 @@
DCFC9ECC28002303005D9144 /* CollectionViewSection.swift in Sources */,
DC89EA602993AC4F00BFF393 /* NSUserActivity+SaveRestore.swift in Sources */,
DC62F567292504060095BB5D /* AccountConnection.swift in Sources */,
DC16213A2B8FEEE500EB17F8 /* OCSidebarItem+Cell.swift in Sources */,
DC9219FD2966229100F538EE /* UniversalItemListCell.swift in Sources */,
DC28F826294B733700AC4013 /* OCItemPolicy+Interactions.swift in Sources */,
DC89EA5C2993A0E000BFF393 /* AppStateActionConnect.swift in Sources */,
Expand Down Expand Up @@ -4732,6 +4773,7 @@
DCDE444D2A36F56000BFF393 /* AppStateActionOpenItem.swift in Sources */,
DCEA89822AD84D6000BFF393 /* BrandView.swift in Sources */,
DC60F2AA29802D5800905EC8 /* NavigationContentItem.swift in Sources */,
DC16213E2B8FF06800EB17F8 /* OCSidebarItem+Interactions.swift in Sources */,
DC0A356F24C0E42700FB58FC /* StaticTableViewController.swift in Sources */,
DC62F569292504510095BB5D /* AccountConnectionPool.swift in Sources */,
DC0A358F24C0E46000FB58FC /* PointerEffect.swift in Sources */,
Expand Down Expand Up @@ -4936,9 +4978,11 @@
DCF2DA7E24C835BF0026D790 /* OCVault+FPServices.m in Sources */,
DC2A128728D0725D0088A2B7 /* OCSavedSearch.m in Sources */,
DCDC208D239912DC003CFF5B /* OCLicenseTransaction.m in Sources */,
DC1621362B8FE26200EB17F8 /* OCVault+SidebarItems.m in Sources */,
DC23D1D9238F390A00423F62 /* OCLicenseAppStoreReceipt.m in Sources */,
DCC832F2242CC28400153F8C /* NotificationMessagePresenter.m in Sources */,
DCF2DA8224C836240026D790 /* OCBookmark+FPServices.m in Sources */,
DC80879A2B8FDFD900AB1C45 /* OCSidebarItem.m in Sources */,
DCFEFE2B236876BD009A142F /* OCLicenseManager.m in Sources */,
DCDC20A22399A715003CFF5B /* OCCore+LicenseEnvironment.m in Sources */,
DCEA7F42282D3B110050A3C0 /* VFSManager.m 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 @@ -88,6 +88,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
OCExtensionManager.shared.addExtension(ImportPasteboardAction.actionExtension)
OCExtensionManager.shared.addExtension(CutAction.actionExtension)
OCExtensionManager.shared.addExtension(CreateDocumentAction.actionExtension)
OCExtensionManager.shared.addExtension(AddToSidebarAction.actionExtension)

if UIDevice.current.isIpad {
// iPad only
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// AddToSidebarAction.swift
// ownCloud
//
// Created by Felix Schwarz on 28.02.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 ownCloudApp
import ownCloudAppShared

class AddToSidebarAction: Action {
override class var identifier : OCExtensionIdentifier? { return OCExtensionIdentifier("com.owncloud.action.addToSidebar") }
override class var category : ActionCategory? { return .normal }
override class var name : String? { return "Add to sidebar".localized }
override class var locations : [OCExtensionLocationIdentifier]? { return [.contextMenuItem, .moreItem] }

// MARK: - Extension matching
override class func applicablePosition(forContext context: ActionContext) -> ActionPosition {
guard context.items.count > 0 else {
return .none
}

for item in context.items {
if item.type != .collection {
return .none
}
}

return .middle
}

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

for item in context.items {
if let location = item.location {
location.bookmarkUUID = context.core?.bookmark.uuid
core.vault.add(OCSidebarItem(location: location))
}
}
}

override class func iconForLocation(_ location: OCExtensionLocationIdentifier) -> UIImage? {
return UIImage(systemName: "sidebar.leading")?.withRenderingMode(.alwaysTemplate)
}

}
37 changes: 37 additions & 0 deletions ownCloudAppFramework/Sidebar Items/OCSidebarItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// OCSidebarItem.h
// ownCloudApp
//
// Created by Felix Schwarz on 28.02.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 <Foundation/Foundation.h>
#import <ownCloudSDK/ownCloudSDK.h>

typedef NSString* OCSidebarItemUUID;

NS_ASSUME_NONNULL_BEGIN

@interface OCSidebarItem : NSObject <NSSecureCoding, OCDataItem, OCDataItemVersioning>

@property(strong,readonly) OCSidebarItemUUID uuid;
@property(strong,nullable) OCLocation *location;

- (instancetype)initWithLocation:(OCLocation *)location;

@end

extern OCDataItemType OCDataItemTypeSidebarItem;

NS_ASSUME_NONNULL_END
104 changes: 104 additions & 0 deletions ownCloudAppFramework/Sidebar Items/OCSidebarItem.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
//
// OCSidebarItem.m
// ownCloudApp
//
// Created by Felix Schwarz on 28.02.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 "OCSidebarItem.h"

@implementation OCSidebarItem

- (instancetype)init
{
if ((self = [super init]) != nil)
{
_uuid = NSUUID.UUID.UUIDString;
}

return (self);
}

- (instancetype)initWithLocation:(OCLocation *)location
{
if ((self = [self init]) != nil)
{
self.location = location;
}

return (self);
}

//! MARK: - Data item
- (OCDataItemType)dataItemType
{
return (OCDataItemTypeSidebarItem);
}

- (OCDataItemReference)dataItemReference
{
return (_uuid);
}

- (OCDataItemVersion)dataItemVersion
{
return ([NSString stringWithFormat:@"%@%@", self.uuid, self.location.lastPathComponent]);
}

//! MARK: - Secure coding
+ (BOOL)supportsSecureCoding
{
return (YES);
}

- (void)encodeWithCoder:(nonnull NSCoder *)coder
{
[coder encodeObject:_uuid forKey:@"uuid"];
[coder encodeObject:_location forKey:@"location"];
}

- (nullable instancetype)initWithCoder:(nonnull NSCoder *)coder
{
if ((self = [self init]) != nil)
{
_uuid = [coder decodeObjectOfClass:NSString.class forKey:@"uuid"];
_location = [coder decodeObjectOfClass:OCLocation.class forKey:@"location"];
}

return (self);
}

//! MARK: - Comparison
- (NSUInteger)hash
{
return (_uuid.hash ^ _location.hash);
}

- (BOOL)isEqual:(id)object
{
OCSidebarItem *otherSidebarItem;

if ((otherSidebarItem = OCTypedCast(object, OCSidebarItem)) != nil)
{
return (OCNAIsEqual(otherSidebarItem.uuid, _uuid) &&
OCNAIsEqual(otherSidebarItem.location, _location)
);
}

return (NO);
}

@end

OCDataItemType OCDataItemTypeSidebarItem = @"sidebarItem";
Loading

0 comments on commit 11076a6

Please sign in to comment.