Skip to content

Commit

Permalink
- update SDK
Browse files Browse the repository at this point in the history
	- adapt BookmarkViewController to latest OCBookmarkManager usage patterns
- improve Illustrator ".ai" support
	- override for failing iOS MIMEType -> UTI conversion in FileProvider (-> fix grayed out items in Files app)
	- add "application/illustrator" mime type to PDFViewerViewController to allow viewing Illustrator files in-app
- improved sorting
	- replace "type" with "kind" to match Files app and change method:
		- sort by type (folder / file)
		- if identical: sort by suffix (with fallback to MIMEType if no suffix is available)
		- if identical: use "_various" for comparison
  • Loading branch information
felix-schwarz committed Apr 16, 2020
1 parent 3fc0fde commit 0c1c582
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 29 deletions.
6 changes: 4 additions & 2 deletions ownCloud File Provider/OCItem+FileProviderItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ - (NSString *)filename
@"application/vnd.oasis.opendocument.spreadsheet-template" : @"org.oasis-open.opendocument.spreadsheet-template",

@"application/vnd.oasis.opendocument.formula" : @"org.oasis-open.opendocument.formula",
@"application/vnd.oasis.opendocument.formula-template" : @"org.oasis-open.opendocument.formula-template"
@"application/vnd.oasis.opendocument.formula-template" : @"org.oasis-open.opendocument.formula-template",

@"application/illustrator" : @"com.adobe.illustrator.ai-image"
};
});

Expand Down Expand Up @@ -173,7 +175,7 @@ - (NSString *)typeIdentifier
}
else
{
uti = (__bridge NSString *)kUTTypeItem;
uti = (__bridge NSString *)kUTTypeData;
}

OCLogDebug(@"Converted %@ MIMEType %@ to UTI %@", self.name, self.mimeType, uti);
Expand Down
6 changes: 3 additions & 3 deletions ownCloud/Bookmarks/BookmarkViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,13 @@ class BookmarkViewController: StaticTableViewController {
case .create:
// Add bookmark
OCBookmarkManager.shared.addBookmark(bookmark)
OCBookmarkManager.shared.saveBookmarks()

case .edit:
// Update original bookmark
self?.originalBookmark?.setValuesFrom(bookmark)
OCBookmarkManager.shared.saveBookmarks()
OCBookmarkManager.shared.postChangeNotification()
if !OCBookmarkManager.shared.updateBookmark(bookmark) {
Log.error("Changes to \(bookmark) not saved as it's not tracked by OCBookmarkManager!")
}
}

let userActionCompletionHandler = strongSelf.userActionCompletionHandler
Expand Down
2 changes: 1 addition & 1 deletion ownCloud/Client/Viewer/PDF/PDFViewerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class PDFViewerViewController: DisplayViewController, DisplayExtension {

static var customMatcher: OCExtensionCustomContextMatcher?
static var displayExtensionIdentifier: String = "org.owncloud.pdfViewer.default"
static var supportedMimeTypes: [String]? = ["application/pdf"]
static var supportedMimeTypes: [String]? = ["application/pdf", "application/illustrator"]
static var features: [String : Any]? = [FeatureKeys.canEdit : false]

deinit {
Expand Down
2 changes: 1 addition & 1 deletion ownCloud/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"Sort by" = "Sort by";

"name" = "name";
"type" = "type";
"kind" = "kind";
"size" = "size";
"date" = "date";
"Search this folder" = "Search this folder";
Expand Down
43 changes: 22 additions & 21 deletions ownCloudAppShared/Client/SortMethod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ public enum SortDirection: Int {
public enum SortMethod: Int {

case alphabetically = 0
case type = 1
case kind = 1
case size = 2
case date = 3
case shared = 4

public static var all: [SortMethod] = [alphabetically, type, size, date, shared]
public static var all: [SortMethod] = [alphabetically, kind, size, date, shared]

public func localizedName() -> String {
var name = ""

switch self {
case .alphabetically:
name = "name".localized
case .type:
name = "type".localized
case .kind:
name = "kind".localized
case .size:
name = "size".localized
case .date:
Expand Down Expand Up @@ -87,34 +87,35 @@ public enum SortMethod: Int {
case .alphabetically:
comparator = alphabeticComparator
combinedComparator = alphabeticComparator
case .type:
case .kind:
comparator = { (left, right) in
let leftItem = left as? OCItem
let rightItem = right as? OCItem

var leftMimeType = leftItem?.mimeType
var rightMimeType = rightItem?.mimeType
let leftKind = leftItem?.fileExtension ?? leftItem?.mimeType ?? "_various"
let rightKind = rightItem?.fileExtension ?? rightItem?.mimeType ?? "_various"

if leftItem?.type == OCItemType.collection {
leftMimeType = "folder"
}

if rightItem?.type == OCItemType.collection {
rightMimeType = "folder"
}
var result : ComparisonResult = leftKind.compare(rightKind)

if leftMimeType == nil {
leftMimeType = "various"
if let leftItemType = leftItem?.type, let rightItemType = rightItem?.type {
if leftItemType != rightItemType {
if leftItemType == .collection, rightItemType == .file {
result = .orderedAscending
} else {
result = .orderedDescending
}
}
}

if rightMimeType == nil {
rightMimeType = "various"
}
if direction == .descendant {
return rightMimeType!.compare(leftMimeType!)
if result == .orderedDescending {
result = .orderedAscending
} else if result == .orderedAscending {
result = .orderedDescending
}
}

return leftMimeType!.compare(rightMimeType!)
return result
}
case .shared:
comparator = { (left, right) in
Expand Down

0 comments on commit 0c1c582

Please sign in to comment.