From f5c2fc4813c3f37b3cf86a3daed0716d99766154 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 21 Jan 2020 12:58:05 -0700 Subject: [PATCH] Pass all UTI types associated with OPML to the document picker for OPML imports. Issue #1684 --- iOS/Settings/SettingsViewController.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/iOS/Settings/SettingsViewController.swift b/iOS/Settings/SettingsViewController.swift index f9c5fe8f0..38afd5646 100644 --- a/iOS/Settings/SettingsViewController.swift +++ b/iOS/Settings/SettingsViewController.swift @@ -8,6 +8,7 @@ import UIKit import Account +import CoreServices import SafariServices class SettingsViewController: UITableViewController { @@ -383,7 +384,17 @@ private extension SettingsViewController { } func importOPMLDocumentPicker() { - let docPicker = UIDocumentPickerViewController(documentTypes: ["public.text"], in: .import) + + let utiArray = UTTypeCreateAllIdentifiersForTag(kUTTagClassFilenameExtension, "opml" as NSString, nil)?.takeRetainedValue() as? [String] ?? [String]() + + var opmlUTIs = utiArray + .compactMap({ UTTypeCopyDeclaration($0 as NSString)?.takeUnretainedValue() as? [String: Any] }) + .reduce([String]()) { (result, dict) in + return result + dict.values.compactMap({ $0 as? String }) + } + opmlUTIs.append("public.xml") + + let docPicker = UIDocumentPickerViewController(documentTypes: opmlUTIs, in: .import) docPicker.delegate = self docPicker.modalPresentationStyle = .formSheet self.present(docPicker, animated: true)