diff --git a/Account/Sources/Account/Account.swift b/Account/Sources/Account/Account.swift index ba985cb01..e0bc64866 100644 --- a/Account/Sources/Account/Account.swift +++ b/Account/Sources/Account/Account.swift @@ -42,7 +42,9 @@ public enum AccountType: Int, Codable { case feedWrangler = 18 case newsBlur = 19 case freshRSS = 20 - // TODO: more + case inoreader = 21 + case bazQux = 22 + case theOldReader = 23 } public enum FetchType { @@ -258,14 +260,20 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, self.delegate = CloudKitAccountDelegate(dataFolder: dataFolder) case .feedbin: self.delegate = FeedbinAccountDelegate(dataFolder: dataFolder, transport: transport) - case .freshRSS: - self.delegate = ReaderAPIAccountDelegate(dataFolder: dataFolder, transport: transport) case .feedly: self.delegate = FeedlyAccountDelegate(dataFolder: dataFolder, transport: transport, api: FeedlyAccountDelegate.environment) case .feedWrangler: self.delegate = FeedWranglerAccountDelegate(dataFolder: dataFolder, transport: transport) case .newsBlur: self.delegate = NewsBlurAccountDelegate(dataFolder: dataFolder, transport: transport) + case .freshRSS: + self.delegate = ReaderAPIAccountDelegate(dataFolder: dataFolder, transport: transport, variant: .generic) + case .inoreader: + self.delegate = ReaderAPIAccountDelegate(dataFolder: dataFolder, transport: transport, variant: .inoreader) + case .bazQux: + self.delegate = ReaderAPIAccountDelegate(dataFolder: dataFolder, transport: transport, variant: .bazQux) + case .theOldReader: + self.delegate = ReaderAPIAccountDelegate(dataFolder: dataFolder, transport: transport, variant: .theOldReader) } self.delegate.accountMetadata = metadata @@ -282,17 +290,23 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, case .onMyMac: defaultName = Account.defaultLocalAccountName case .cloudKit: - defaultName = "iCloud" + defaultName = NSLocalizedString("iCloud", comment: "iCloud") case .feedly: - defaultName = "Feedly" + defaultName = NSLocalizedString("Feedly", comment: "Feedly") case .feedbin: - defaultName = "Feedbin" + defaultName = NSLocalizedString("Feedbin", comment: "Feedbin") case .feedWrangler: - defaultName = "FeedWrangler" + defaultName = NSLocalizedString("FeedWrangler", comment: "FeedWrangler") case .newsBlur: - defaultName = "NewsBlur" + defaultName = NSLocalizedString("NewsBlur", comment: "NewsBlur") case .freshRSS: - defaultName = "FreshRSS" + defaultName = NSLocalizedString("FreshRSS", comment: "FreshRSS") + case .inoreader: + defaultName = NSLocalizedString("Inoreader", comment: "Inoreader") + case .bazQux: + defaultName = NSLocalizedString("BazQux", comment: "BazQux") + case .theOldReader: + defaultName = NSLocalizedString("The Old Reader", comment: "The Old Reader") } NotificationCenter.default.addObserver(self, selector: #selector(downloadProgressDidChange(_:)), name: .DownloadProgressDidChange, object: nil) diff --git a/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift b/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift index 06f1eb5b5..773975de2 100644 --- a/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift +++ b/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift @@ -21,6 +21,12 @@ public enum ReaderAPIAccountDelegateError: String, Error { final class ReaderAPIAccountDelegate: AccountDelegate { + private var variant: ReaderAPIVariant { + didSet { + caller.variant = variant + } + } + private let database: SyncDatabase private let caller: ReaderAPICaller @@ -50,8 +56,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate { var refreshProgress = DownloadProgress(numberOfTasks: 0) - init(dataFolder: String, transport: Transport?) { - + init(dataFolder: String, transport: Transport?, variant: ReaderAPIVariant) { let databaseFilePath = (dataFolder as NSString).appendingPathComponent("Sync.sqlite3") database = SyncDatabase(databaseFilePath: databaseFilePath) @@ -78,6 +83,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate { } + self.variant = variant } func receiveRemoteNotification(for account: Account, userInfo: [AnyHashable : Any], completion: @escaping () -> Void) { diff --git a/Account/Sources/Account/ReaderAPI/ReaderAPICaller.swift b/Account/Sources/Account/ReaderAPI/ReaderAPICaller.swift index 30e9094ee..505b60933 100644 --- a/Account/Sources/Account/ReaderAPI/ReaderAPICaller.swift +++ b/Account/Sources/Account/ReaderAPI/ReaderAPICaller.swift @@ -49,6 +49,7 @@ final class ReaderAPICaller: NSObject { private var transport: Transport! + var variant: ReaderAPIVariant = .generic var credentials: Credentials? private var accessToken: String? diff --git a/Account/Sources/Account/ReaderAPI/ReaderAPIVariant.swift b/Account/Sources/Account/ReaderAPI/ReaderAPIVariant.swift new file mode 100644 index 000000000..61bb03980 --- /dev/null +++ b/Account/Sources/Account/ReaderAPI/ReaderAPIVariant.swift @@ -0,0 +1,15 @@ +// +// ReaderAPIVariant.swift +// +// +// Created by Maurice Parker on 10/23/20. +// + +import Foundation + +enum ReaderAPIVariant { + case generic + case inoreader + case bazQux + case theOldReader +} diff --git a/Mac/AppAssets.swift b/Mac/AppAssets.swift index 731880985..a688b29b0 100644 --- a/Mac/AppAssets.swift +++ b/Mac/AppAssets.swift @@ -12,12 +12,12 @@ import Account struct AppAssets { - static var accountCloudKit: RSImage! = { - return RSImage(named: "accountCloudKit") + static var accountBazQux: RSImage! = { + return RSImage(named: "accountBazQux") }() - static var accountLocal: RSImage! = { - return RSImage(named: "accountLocal") + static var accountCloudKit: RSImage! = { + return RSImage(named: "accountCloudKit") }() static var accountFeedbin: RSImage! = { @@ -36,10 +36,22 @@ struct AppAssets { return RSImage(named: "accountFreshRSS") }() + static var accountInoreader: RSImage! = { + return RSImage(named: "accountInoreader") + }() + + static var accountLocal: RSImage! = { + return RSImage(named: "accountLocal") + }() + static var accountNewsBlur: RSImage! = { return RSImage(named: "accountNewsBlur") }() + static var accountTheOldReader: RSImage! = { + return RSImage(named: "accountTheOldReader") + }() + @available(macOS 11.0, *) static var addNewSidebarItemImage: RSImage = { return NSImage(systemSymbolName: "plus", accessibilityDescription: nil)! @@ -293,6 +305,8 @@ struct AppAssets { return AppAssets.accountLocal case .cloudKit: return AppAssets.accountCloudKit + case .bazQux: + return AppAssets.accountBazQux case .feedbin: return AppAssets.accountFeedbin case .feedly: @@ -301,8 +315,12 @@ struct AppAssets { return AppAssets.accountFeedWrangler case .freshRSS: return AppAssets.accountFreshRSS + case .inoreader: + return AppAssets.accountInoreader case .newsBlur: return AppAssets.accountNewsBlur + case .theOldReader: + return AppAssets.accountTheOldReader } } diff --git a/Mac/Preferences/Accounts/AccountsAddViewController.swift b/Mac/Preferences/Accounts/AccountsAddViewController.swift index 60c52ed01..42afd0bef 100644 --- a/Mac/Preferences/Accounts/AccountsAddViewController.swift +++ b/Mac/Preferences/Accounts/AccountsAddViewController.swift @@ -17,9 +17,9 @@ class AccountsAddViewController: NSViewController { private var accountsAddWindowController: NSWindowController? #if DEBUG - private var addableAccountTypes: [AccountType] = [.onMyMac, .feedbin, .feedly, .feedWrangler, .freshRSS, .cloudKit, .newsBlur] + private var addableAccountTypes: [AccountType] = [.onMyMac, .cloudKit, .feedbin, .feedly, .inoreader, .newsBlur, .feedWrangler, .bazQux, .theOldReader, .freshRSS] #else - private var addableAccountTypes: [AccountType] = [.onMyMac, .feedbin, .feedly, .cloudKit, .newsBlur] + private var addableAccountTypes: [AccountType] = [.onMyMac, .cloudKit, .feedbin, .feedly, .inoreader, .newsBlur, .feedWrangler, .bazQux, .theOldReader, .freshRSS] #endif init() { @@ -87,6 +87,15 @@ extension AccountsAddViewController: NSTableViewDelegate { case .newsBlur: cell.accountNameLabel?.stringValue = NSLocalizedString("NewsBlur", comment: "NewsBlur") cell.accountImageView?.image = AppAssets.accountNewsBlur + case .inoreader: + cell.accountNameLabel?.stringValue = NSLocalizedString("Inoreader", comment: "Inoreader") + cell.accountImageView?.image = AppAssets.accountInoreader + case .bazQux: + cell.accountNameLabel?.stringValue = NSLocalizedString("Bazqux", comment: "Bazqux") + cell.accountImageView?.image = AppAssets.accountBazQux + case .theOldReader: + cell.accountNameLabel?.stringValue = NSLocalizedString("The Old Reader", comment: "The Old Reader") + cell.accountImageView?.image = AppAssets.accountTheOldReader } return cell } @@ -137,15 +146,32 @@ extension AccountsAddViewController: AccountsAddTableCellViewDelegate { let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly) addAccount.delegate = self addAccount.presentationAnchor = self.view.window! - runAwaitingFeedlyLoginAlertModal(forLifetimeOf: addAccount) - MainThreadOperationQueue.shared.add(addAccount) case .newsBlur: let accountsNewsBlurWindowController = AccountsNewsBlurWindowController() accountsNewsBlurWindowController.runSheetOnWindow(self.view.window!) accountsAddWindowController = accountsNewsBlurWindowController + + case .inoreader: + let accountsReaderAPIWindowController = AccountsReaderAPIWindowController() + accountsReaderAPIWindowController.accountType = .inoreader + accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!) + accountsAddWindowController = accountsReaderAPIWindowController + + case .bazQux: + let accountsReaderAPIWindowController = AccountsReaderAPIWindowController() + accountsReaderAPIWindowController.accountType = .bazQux + accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!) + accountsAddWindowController = accountsReaderAPIWindowController + + case .theOldReader: + let accountsReaderAPIWindowController = AccountsReaderAPIWindowController() + accountsReaderAPIWindowController.accountType = .theOldReader + accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!) + accountsAddWindowController = accountsReaderAPIWindowController + } } diff --git a/Mac/Preferences/Accounts/AccountsReaderAPIWindowController.swift b/Mac/Preferences/Accounts/AccountsReaderAPIWindowController.swift index 948902a21..2eeeff8c7 100644 --- a/Mac/Preferences/Accounts/AccountsReaderAPIWindowController.swift +++ b/Mac/Preferences/Accounts/AccountsReaderAPIWindowController.swift @@ -38,6 +38,15 @@ class AccountsReaderAPIWindowController: NSWindowController { case .freshRSS: titleImageView.image = AppAssets.accountFreshRSS titleLabel.stringValue = NSLocalizedString("FreshRSS", comment: "FreshRSS") + case .inoreader: + titleImageView.image = AppAssets.accountInoreader + titleLabel.stringValue = NSLocalizedString("InoReader", comment: "InoReader") + case .bazQux: + titleImageView.image = AppAssets.accountBazQux + titleLabel.stringValue = NSLocalizedString("BazQux", comment: "BazQux") + case .theOldReader: + titleImageView.image = AppAssets.accountTheOldReader + titleLabel.stringValue = NSLocalizedString("The Old Reader", comment: "The Old Reader") default: break } diff --git a/Mac/Resources/Assets.xcassets/accountBazQux.imageset/Contents.json b/Mac/Resources/Assets.xcassets/accountBazQux.imageset/Contents.json new file mode 100644 index 000000000..5dc93b35e --- /dev/null +++ b/Mac/Resources/Assets.xcassets/accountBazQux.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "bazqux-logo.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/Mac/Resources/Assets.xcassets/accountBazQux.imageset/bazqux-logo.png b/Mac/Resources/Assets.xcassets/accountBazQux.imageset/bazqux-logo.png new file mode 100644 index 000000000..a73b4eb8c Binary files /dev/null and b/Mac/Resources/Assets.xcassets/accountBazQux.imageset/bazqux-logo.png differ diff --git a/Mac/Resources/Assets.xcassets/accountInoreader.imageset/Contents.json b/Mac/Resources/Assets.xcassets/accountInoreader.imageset/Contents.json new file mode 100644 index 000000000..979b7673c --- /dev/null +++ b/Mac/Resources/Assets.xcassets/accountInoreader.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "inoreader_logo.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/Mac/Resources/Assets.xcassets/accountInoreader.imageset/inoreader_logo.pdf b/Mac/Resources/Assets.xcassets/accountInoreader.imageset/inoreader_logo.pdf new file mode 100644 index 000000000..6ae613d52 Binary files /dev/null and b/Mac/Resources/Assets.xcassets/accountInoreader.imageset/inoreader_logo.pdf differ diff --git a/Mac/Resources/Assets.xcassets/accountTheOldReader.imageset/Contents.json b/Mac/Resources/Assets.xcassets/accountTheOldReader.imageset/Contents.json new file mode 100644 index 000000000..54e6957d5 --- /dev/null +++ b/Mac/Resources/Assets.xcassets/accountTheOldReader.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "oldreader-icon.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/Mac/Resources/Assets.xcassets/accountTheOldReader.imageset/oldreader-icon.pdf b/Mac/Resources/Assets.xcassets/accountTheOldReader.imageset/oldreader-icon.pdf new file mode 100644 index 000000000..8a8a3baa6 Binary files /dev/null and b/Mac/Resources/Assets.xcassets/accountTheOldReader.imageset/oldreader-icon.pdf differ diff --git a/Mac/Scriptability/Account+Scriptability.swift b/Mac/Scriptability/Account+Scriptability.swift index 8e3b00edc..7e97dd88b 100644 --- a/Mac/Scriptability/Account+Scriptability.swift +++ b/Mac/Scriptability/Account+Scriptability.swift @@ -170,6 +170,12 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta osType = "NBlr" case .freshRSS: osType = "Frsh" + case .inoreader: + osType = "Inrd" + case .bazQux: + osType = "Bzqx" + case .theOldReader: + osType = "Tord" } return osType.fourCharCode }