-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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
1 parent
2a4d536
commit 11076a6
Showing
19 changed files
with
676 additions
and
14 deletions.
There are no files selected for viewing
Submodule ios-sdk
updated
8 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
ownCloud/Client/Actions/Actions+Extensions/AddToSidebarAction.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
Oops, something went wrong.