Renamed google reader api to just reader api to make it consistent everywhere we use it

This commit is contained in:
Maurice Parker 2019-06-19 15:40:03 -05:00
parent 1e53d0b463
commit b4b80c51bc
15 changed files with 65 additions and 45 deletions

View File

@ -33,7 +33,7 @@ public enum AccountType: Int {
case feedbin = 17
case feedWrangler = 18
case newsBlur = 19
case googleReaderAPI = 20
case readerAPI = 20
// TODO: more
}
@ -217,7 +217,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
self.delegate = LocalAccountDelegate()
case .feedbin:
self.delegate = FeedbinAccountDelegate(dataFolder: dataFolder, transport: transport)
case .googleReaderAPI:
case .readerAPI:
self.delegate = ReaderAPIAccountDelegate(dataFolder: dataFolder, transport: transport)
default:
fatalError("Only Local and Feedbin accounts are supported")
@ -246,8 +246,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
defaultName = "FeedWrangler"
case .newsBlur:
defaultName = "NewsBlur"
case .googleReaderAPI:
defaultName = "Reader"
case .readerAPI:
defaultName = "Reader API"
}
NotificationCenter.default.addObserver(self, selector: #selector(downloadProgressDidChange(_:)), name: .DownloadProgressDidChange, object: nil)
@ -279,9 +279,9 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
switch credentials {
case .basic(let username, _):
self.username = username
case .googleBasicLogin(let username, _):
case .readerAPIBasicLogin(let username, _):
self.username = username
case .googleAuthLogin(let username, _):
case .readerAPIAuthLogin(let username, _):
self.username = username
}
@ -306,18 +306,18 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
self.username = nil
}
public func retrieveGoogleAuthCredentials() throws -> Credentials? {
public func retrieveReaderAPIAuthCredentials() throws -> Credentials? {
guard let username = self.username, let server = delegate.server else {
return nil
}
return try CredentialsManager.retrieveGoogleAuthCredentials(server: server, username: username)
return try CredentialsManager.retrieveReaderAPIAuthCredentials(server: server, username: username)
}
public func removeGoogleAuthCredentials() throws {
public func removeReaderAPIAuthCredentials() throws {
guard let username = self.username, let server = delegate.server else {
return
}
try CredentialsManager.removeGoogleAuthCredentials(server: server, username: username)
try CredentialsManager.removeReaderAPIAuthCredentials(server: server, username: username)
self.username = nil
}
@ -327,7 +327,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
LocalAccountDelegate.validateCredentials(transport: transport, credentials: credentials, completion: completion)
case .feedbin:
FeedbinAccountDelegate.validateCredentials(transport: transport, credentials: credentials, completion: completion)
case .googleReaderAPI:
case .readerAPI:
ReaderAPIAccountDelegate.validateCredentials(transport: transport, credentials: credentials, endpoint: endpoint, completion: completion)
default:
break

View File

@ -538,7 +538,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
func accountDidInitialize(_ account: Account) {
accountMetadata = account.metadata
credentials = try? account.retrieveGoogleAuthCredentials()
credentials = try? account.retrieveReaderAPIAuthCredentials()
}
static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL?, completion: @escaping (Result<Credentials?, Error>) -> Void) {

View File

@ -84,7 +84,7 @@ final class ReaderAPICaller: NSObject {
return
}
guard case .googleBasicLogin(let username, _) = credentials else {
guard case .readerAPIBasicLogin(let username, _) = credentials else {
completion(.failure(CredentialsError.incompleteCredentials))
return
}
@ -117,7 +117,7 @@ final class ReaderAPICaller: NSObject {
}
// Save Auth Token for later use
self.credentials = .googleAuthLogin(username: username, apiKey: authString)
self.credentials = .readerAPIAuthLogin(username: username, apiKey: authString)
completion(.success(self.credentials))
case .failure(let error):

View File

@ -34,6 +34,10 @@ struct AppAssets {
return RSImage(named: "accountFeedbin")
}()
static var accountReader: RSImage! = {
return RSImage(named: "accountReader")
}()
static var faviconTemplateImage: RSImage = {
return RSImage(named: "faviconTemplateImage")!
}()

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14810.12" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14810.12"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@ -18,13 +19,13 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="398" height="205"/>
<rect key="screenRect" x="0.0" y="0.0" width="2048" height="1129"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="398" height="205"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView distribution="fill" orientation="horizontal" alignment="bottom" spacing="19" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uDK-ji-zlT">
<rect key="frame" x="95" y="150" width="209" height="39"/>
<rect key="frame" x="93" y="151" width="213" height="38"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ySx-qg-WbT">
<rect key="frame" x="0.0" y="0.0" width="36" height="36"/>
@ -35,7 +36,7 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="accountLocal" id="9RZ-J3-ioX"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="80D-3X-rL2">
<rect key="frame" x="53" y="0.0" width="158" height="39"/>
<rect key="frame" x="53" y="0.0" width="162" height="38"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="On My Mac" id="1d2-Mx-TKe">
<font key="font" metaFont="system" size="32"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -53,10 +54,10 @@
</customSpacing>
</stackView>
<stackView distribution="fill" orientation="horizontal" alignment="firstBaseline" spacing="18" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6Q7-nI-h5u">
<rect key="frame" x="100" y="107" width="198" height="27"/>
<rect key="frame" x="100" y="105" width="198" height="30"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="MWg-UL-xtj">
<rect key="frame" x="-2" y="8" width="44" height="17"/>
<rect key="frame" x="-2" y="12" width="44" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Name:" id="AVh-ns-LEN">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@ -64,7 +65,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="f9b-FM-i8Q">
<rect key="frame" x="58" y="5" width="140" height="22"/>
<rect key="frame" x="58" y="9" width="140" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="140" id="cdf-tS-vno"/>
</constraints>
@ -111,7 +112,7 @@ Gw
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3Kj-Cl-FJQ">
<rect key="frame" x="87" y="57" width="224" height="34"/>
<rect key="frame" x="87" y="57" width="224" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="220" id="xiK-wa-r3v"/>
</constraints>

View File

@ -64,8 +64,8 @@ extension AccountsAddViewController: NSTableViewDelegate {
cell.accountNameLabel?.stringValue = NSLocalizedString("Feedbin", comment: "Feedbin")
cell.accountImageView?.image = AppAssets.accountFeedbin
case 2:
cell.accountNameLabel?.stringValue = NSLocalizedString("Reader", comment: "Reader")
cell.accountImageView?.image = AppAssets.accountLocal
cell.accountNameLabel?.stringValue = NSLocalizedString("Reader API", comment: "Reader API")
cell.accountImageView?.image = AppAssets.accountReader
default:
break
}

View File

@ -107,8 +107,8 @@ extension AccountsPreferencesViewController: NSTableViewDelegate {
cell.imageView?.image = AppAssets.accountLocal
case .feedbin:
cell.imageView?.image = NSImage(named: "accountFeedbin")
case .googleReaderAPI:
cell.imageView?.image = AppAssets.accountLocal
case .readerAPI:
cell.imageView?.image = AppAssets.accountReader
default:
break
}

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14810.11" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14810.12" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14810.11"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14810.12"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@ -23,13 +23,13 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="433" height="249"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1440"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" misplaced="YES" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="433" height="249"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView distribution="fill" orientation="horizontal" alignment="bottom" spacing="19" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7Ht-Fn-0Ya">
<rect key="frame" x="140" y="220" width="153" height="38"/>
<rect key="frame" x="113" y="220" width="207" height="38"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Ssh-Dh-xbg">
<rect key="frame" x="0.0" y="0.0" width="36" height="36"/>
@ -37,11 +37,11 @@
<constraint firstAttribute="height" constant="36" id="Ern-Kk-8LX"/>
<constraint firstAttribute="width" constant="36" id="PLS-68-NMc"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="accountLocal" id="y38-YL-woC"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="accountReader" id="y38-YL-woC"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lti-yM-8LV">
<rect key="frame" x="53" y="0.0" width="102" height="38"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Reader" id="ras-dj-nP8">
<rect key="frame" x="53" y="0.0" width="156" height="38"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Reader API" id="ras-dj-nP8">
<font key="font" metaFont="system" size="32"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@ -206,6 +206,6 @@ Gw
</window>
</objects>
<resources>
<image name="accountLocal" width="78" height="98"/>
<image name="accountReader" width="73" height="73"/>
</resources>
</document>

View File

@ -70,8 +70,8 @@ class AccountsReaderAPIWindowController: NSWindowController {
return
}
let credentials = Credentials.googleBasicLogin(username: usernameTextField.stringValue, password: passwordTextField.stringValue)
Account.validateCredentials(type: .googleReaderAPI, credentials: credentials, endpoint: apiURL) { [weak self] result in
let credentials = Credentials.readerAPIBasicLogin(username: usernameTextField.stringValue, password: passwordTextField.stringValue)
Account.validateCredentials(type: .readerAPI, credentials: credentials, endpoint: apiURL) { [weak self] result in
guard let self = self else { return }
@ -89,14 +89,14 @@ class AccountsReaderAPIWindowController: NSWindowController {
var newAccount = false
if self.account == nil {
self.account = AccountManager.shared.createAccount(type: .googleReaderAPI)
self.account = AccountManager.shared.createAccount(type: .readerAPI)
newAccount = true
}
do {
self.account?.endpointURL = apiURL
try self.account?.removeGoogleAuthCredentials()
try self.account?.removeReaderAPIAuthCredentials()
try self.account?.storeCredentials(validatedCredentials)
if newAccount {

View File

@ -0,0 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "accountReader.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}

View File

@ -142,7 +142,7 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
osType = "FWrg"
case .newsBlur:
osType = "NBlr"
case .googleReaderAPI:
case .readerAPI:
osType = "Grdr"
}
return osType.fourCharCode()

View File

@ -77,13 +77,13 @@ struct SettingsReaderAPIAccountView : View {
error = Text("")
let emailAddress = viewModel.email.trimmingCharacters(in: .whitespaces)
let credentials = Credentials.googleBasicLogin(username: emailAddress, password: viewModel.password)
let credentials = Credentials.readerAPIBasicLogin(username: emailAddress, password: viewModel.password)
guard let apiURL = URL(string: viewModel.apiURL) else {
self.error = Text("Invalide API URL.")
return
}
Account.validateCredentials(type: .googleReaderAPI, credentials: credentials, endpoint: apiURL) { result in
Account.validateCredentials(type: .readerAPI, credentials: credentials, endpoint: apiURL) { result in
self.busy = false
@ -95,7 +95,7 @@ struct SettingsReaderAPIAccountView : View {
var newAccount = false
let workAccount: Account
if self.viewModel.account == nil {
workAccount = AccountManager.shared.createAccount(type: .googleReaderAPI)
workAccount = AccountManager.shared.createAccount(type: .readerAPI)
newAccount = true
} else {
workAccount = self.viewModel.account!

@ -1 +1 @@
Subproject commit f2be15379d64e2f660735219bcbd77f7a759b057
Subproject commit 52a23c95d4cfd52b827c9f571a2271376ed070fd

@ -1 +1 @@
Subproject commit 4f8844750e9c25b0e43f9ead3de582d32a1321de
Subproject commit afcbd0819c85b263acc892361ed840a9628eba4d