From ce0e548e79717651829f4e37a31e21f89cf952d7 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 17 Apr 2019 07:00:32 -0500 Subject: [PATCH] Established settings menu with built in OPML Import/Export. --- iOS/Base.lproj/Main.storyboard | 14 ++-- iOS/Master/MasterPrimaryViewController.swift | 57 --------------- iOS/Master/MasterViewController.swift | 68 ++++++++++++++++++ .../settingsImage.imageset/Contents.json | 2 +- .../{settings.pdf => settings3.pdf} | Bin 6292 -> 4281 bytes 5 files changed, 74 insertions(+), 67 deletions(-) rename iOS/Resources/Assets.xcassets/settingsImage.imageset/{settings.pdf => settings3.pdf} (53%) diff --git a/iOS/Base.lproj/Main.storyboard b/iOS/Base.lproj/Main.storyboard index 347b5c3b1..2b4a9e2e9 100644 --- a/iOS/Base.lproj/Main.storyboard +++ b/iOS/Base.lproj/Main.storyboard @@ -205,14 +205,11 @@ - - - - - - - - + + + + + @@ -287,7 +284,6 @@ - diff --git a/iOS/Master/MasterPrimaryViewController.swift b/iOS/Master/MasterPrimaryViewController.swift index ad7d8d096..23b78396b 100644 --- a/iOS/Master/MasterPrimaryViewController.swift +++ b/iOS/Master/MasterPrimaryViewController.swift @@ -12,47 +12,6 @@ import RSCore import RSTree class MasterPrimaryViewController: MasterViewController { - - // MARK: Actions - - @IBAction func showOPMLImportExport(_ sender: UIBarButtonItem) { - - let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) - - let importOPML = UIAlertAction(title: "Import OPML", style: .default) { [unowned self] alertAction in - let docPicker = UIDocumentPickerViewController(documentTypes: ["public.xml", "org.opml.opml"], in: .import) - docPicker.delegate = self - docPicker.modalPresentationStyle = .formSheet - self.present(docPicker, animated: true) - } - optionMenu.addAction(importOPML) - - let exportOPML = UIAlertAction(title: "Export OPML", style: .default) { [unowned self] alertAction in - - let filename = "MySubscriptions.opml" - let tempFile = FileManager.default.temporaryDirectory.appendingPathComponent(filename) - let opmlString = OPMLExporter.OPMLString(with: AccountManager.shared.localAccount, title: filename) - do { - try opmlString.write(to: tempFile, atomically: true, encoding: String.Encoding.utf8) - } catch { - self.presentError(title: "OPML Export Error", message: error.localizedDescription) - } - - let docPicker = UIDocumentPickerViewController(url: tempFile, in: .exportToService) - docPicker.modalPresentationStyle = .formSheet - self.present(docPicker, animated: true) - - } - optionMenu.addAction(exportOPML) - optionMenu.addAction(UIAlertAction(title: "Cancel", style: .cancel)) - - if let popoverController = optionMenu.popoverPresentationController { - popoverController.barButtonItem = sender - } - - self.present(optionMenu, animated: true) - - } // MARK: - Table View @@ -103,19 +62,3 @@ class MasterPrimaryViewController: MasterViewController { } } - -extension MasterPrimaryViewController: UIDocumentPickerDelegate { - - func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { - - for url in urls { - do { - try OPMLImporter.parseAndImport(fileURL: url, account: AccountManager.shared.localAccount) - } catch { - presentError(title: "OPML Import Error", message: error.localizedDescription) - } - } - - } - -} diff --git a/iOS/Master/MasterViewController.swift b/iOS/Master/MasterViewController.swift index bc139c841..9cf81bb18 100644 --- a/iOS/Master/MasterViewController.swift +++ b/iOS/Master/MasterViewController.swift @@ -193,6 +193,56 @@ class MasterViewController: UITableViewController, UndoableCommandRunner { // MARK: Actions + @IBAction func showTools(_ sender: UIBarButtonItem) { + + let optionMenu = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) + + // Settings Button + let settingsTitle = NSLocalizedString("Settings", comment: "Settings") + let setting = UIAlertAction(title: settingsTitle, style: .default) { alertAction in + + } + optionMenu.addAction(setting) + + // Import Button + let importOPMLTitle = NSLocalizedString("Import OPML", comment: "Import OPML") + let importOPML = UIAlertAction(title: importOPMLTitle, style: .default) { [unowned self] alertAction in + let docPicker = UIDocumentPickerViewController(documentTypes: ["public.xml", "org.opml.opml"], in: .import) + docPicker.delegate = self + docPicker.modalPresentationStyle = .formSheet + self.present(docPicker, animated: true) + } + optionMenu.addAction(importOPML) + + // Export Button + let exportOPMLTitle = NSLocalizedString("Export OPML", comment: "Export OPML") + let exportOPML = UIAlertAction(title: exportOPMLTitle, style: .default) { [unowned self] alertAction in + + let filename = "MySubscriptions.opml" + let tempFile = FileManager.default.temporaryDirectory.appendingPathComponent(filename) + let opmlString = OPMLExporter.OPMLString(with: AccountManager.shared.localAccount, title: filename) + do { + try opmlString.write(to: tempFile, atomically: true, encoding: String.Encoding.utf8) + } catch { + self.presentError(title: "OPML Export Error", message: error.localizedDescription) + } + + let docPicker = UIDocumentPickerViewController(url: tempFile, in: .exportToService) + docPicker.modalPresentationStyle = .formSheet + self.present(docPicker, animated: true) + + } + optionMenu.addAction(exportOPML) + optionMenu.addAction(UIAlertAction(title: "Cancel", style: .cancel)) + + if let popoverController = optionMenu.popoverPresentationController { + popoverController.barButtonItem = sender + } + + self.present(optionMenu, animated: true) + + } + @IBAction func markAllAsRead(_ sender: Any) { let title = NSLocalizedString("Mark All Read", comment: "Mark All Read") @@ -323,6 +373,24 @@ class MasterViewController: UITableViewController, UndoableCommandRunner { } +// MARK: OPML Document Picker + +extension MasterViewController: UIDocumentPickerDelegate { + + func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { + + for url in urls { + do { + try OPMLImporter.parseAndImport(fileURL: url, account: AccountManager.shared.localAccount) + } catch { + presentError(title: "OPML Import Error", message: error.localizedDescription) + } + } + + } + +} + // MARK: Private private extension MasterViewController { diff --git a/iOS/Resources/Assets.xcassets/settingsImage.imageset/Contents.json b/iOS/Resources/Assets.xcassets/settingsImage.imageset/Contents.json index 228b81a81..424b5d41f 100644 --- a/iOS/Resources/Assets.xcassets/settingsImage.imageset/Contents.json +++ b/iOS/Resources/Assets.xcassets/settingsImage.imageset/Contents.json @@ -2,7 +2,7 @@ "images" : [ { "idiom" : "universal", - "filename" : "settings.pdf" + "filename" : "settings3.pdf" } ], "info" : { diff --git a/iOS/Resources/Assets.xcassets/settingsImage.imageset/settings.pdf b/iOS/Resources/Assets.xcassets/settingsImage.imageset/settings3.pdf similarity index 53% rename from iOS/Resources/Assets.xcassets/settingsImage.imageset/settings.pdf rename to iOS/Resources/Assets.xcassets/settingsImage.imageset/settings3.pdf index 87bba4b2125c8b82d131d92f48fe438609a5872a..04f6b8737ed1f6d14df001861e2569e64b9bbf80 100644 GIT binary patch delta 872 zcmbPYxKnXLKz(Y6;ihOso;UY3OBw}QR2;VME~&3!G5377^T%YR>*u@D4|pDXEE(Z& zXz|y}`QD-O`N=N}>MP|!-+hfbWt+iQ}`<|}0h z>pio~n#Ja=o+jkcxvH_`$VIn$ofmP_*jyHuchzv8=IE-rQ#}1~?dJUXj%p{ICta!5 zZIhqo*;_@fTM7RG~ASLj`+%AKQ zWv%FuMSs_y?ezU1^ULLk`0q}~eMi+x?!+Wrzj!=0@`cn%eX1IQxGLPj`QoQsYX^ODQfXN=?iKvGS9$xJ(rc6u`8h z0Zhnf@lm9`SSlERfI^-E7nosSU}gl=k1A$tYGOFq zSzM*wz|6o5UDCkZ0E-4}>dcMN^%|R4V3=oYW@Ln+&deMnCWzuvV{;Sp$=}88;!VvA zjT2K1(-KXRElkoZQj&o@%Fw=#uMNX4M`*RL-c6D}B5*`fDcAipbKDE0# zJFPjGR?0hBG+`Yc%sJbwqs&vk#;((%Hlf1sna#Ys^ z2HSUyKPMwnWvZ8zGk0CZQ7JP<@^<;!TQe7WWS*IWGmVl9wmubqj|f>rdxxZ6w?la_ z7``i7o2A&~wTr9U(XQAJ_&HzgZd$n@e&s-#N|&{n>+yRWTR@!kJG{VnCGoGuPY!`8jD;<8|g?-s1NyF`aQ=ySf;X=1qPldG^k3 z|17!Gee9lsB5!X#{#cas6Htv8FOi zPQ;~ARZw*|!iBPg12PbDB;)I#H~lxy0`eO4e4d#rbdF*j61WA5DJ-jmdALE1xxZEN ztJ(WjN*TK5K(Le_R{CM?MQF{MV<;7Pl_dBaWrP$j8 z6^;gR^+R%X_&e-uFCnlL^TlOuV5bHK5^#H4$w4D}`0rah_rApCz%y(w%(y(b+Ac>E zB1v3x!lg^cJ@RjLSr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