From 1e8623b0ee09b120392060fa951e56ea4b9e02b6 Mon Sep 17 00:00:00 2001 From: aerych Date: Fri, 27 Jul 2018 15:31:16 -0500 Subject: [PATCH 01/11] Sharing: Adds new field to model and bumps model version. --- MIGRATIONS.md | 4 + .../Classes/Models/PublicizeService.swift | 1 + .../WordPress.xcdatamodeld/.xccurrentversion | 2 +- .../WordPress 77.xcdatamodel/contents | 712 ++++++++++++++++++ WordPress/WordPress.xcodeproj/project.pbxproj | 4 +- 5 files changed, 721 insertions(+), 2 deletions(-) create mode 100644 WordPress/Classes/WordPress.xcdatamodeld/WordPress 77.xcdatamodel/contents diff --git a/MIGRATIONS.md b/MIGRATIONS.md index fea896c1bdc3..cfa402cc5560 100644 --- a/MIGRATIONS.md +++ b/MIGRATIONS.md @@ -3,6 +3,10 @@ This file documents changes in the data model. Please explain any changes to the data model as well as any custom migrations. +## WordPress 77 +- @aerych 2018-07-27 +- `SharingService` added `externalUsersOnly` (bool) property. A new field returned by the API. + ## WordPress 76 - @frosty 2018-05-16 diff --git a/WordPress/Classes/Models/PublicizeService.swift b/WordPress/Classes/Models/PublicizeService.swift index a5532d5b93fe..543efd1a7059 100644 --- a/WordPress/Classes/Models/PublicizeService.swift +++ b/WordPress/Classes/Models/PublicizeService.swift @@ -6,6 +6,7 @@ open class PublicizeService: NSManagedObject { @NSManaged open var connectURL: String @NSManaged open var detail: String + @NSManaged open var externalUsersOnly: Bool @NSManaged open var icon: String @NSManaged open var jetpackSupport: Bool @NSManaged open var jetpackModuleRequired: String diff --git a/WordPress/Classes/WordPress.xcdatamodeld/.xccurrentversion b/WordPress/Classes/WordPress.xcdatamodeld/.xccurrentversion index 099cde710486..cd0bfbbbbc89 100644 --- a/WordPress/Classes/WordPress.xcdatamodeld/.xccurrentversion +++ b/WordPress/Classes/WordPress.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - WordPress 76.xcdatamodel + WordPress 77.xcdatamodel diff --git a/WordPress/Classes/WordPress.xcdatamodeld/WordPress 77.xcdatamodel/contents b/WordPress/Classes/WordPress.xcdatamodeld/WordPress 77.xcdatamodel/contents new file mode 100644 index 000000000000..81c556997fb5 --- /dev/null +++ b/WordPress/Classes/WordPress.xcdatamodeld/WordPress 77.xcdatamodel/contents @@ -0,0 +1,712 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WordPress/WordPress.xcodeproj/project.pbxproj b/WordPress/WordPress.xcodeproj/project.pbxproj index 29bf6e144349..9926a832fd41 100644 --- a/WordPress/WordPress.xcodeproj/project.pbxproj +++ b/WordPress/WordPress.xcodeproj/project.pbxproj @@ -2824,6 +2824,7 @@ E6805D2F1DCD399600168E4F /* WPRichTextMediaAttachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WPRichTextMediaAttachment.swift; path = WPRichText/WPRichTextMediaAttachment.swift; sourceTree = ""; }; E68580F51E0D91470090EE63 /* WPHorizontalRuleAttachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WPHorizontalRuleAttachment.swift; sourceTree = ""; }; E69551F51B8B6AE200CB8E4F /* ReaderStreamViewController+Helper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ReaderStreamViewController+Helper.swift"; sourceTree = ""; }; + E699E530210BB719008ED8A7 /* WordPress 77.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "WordPress 77.xcdatamodel"; sourceTree = ""; }; E69BA1961BB5D7D300078740 /* WPStyleGuide+ReadableMargins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WPStyleGuide+ReadableMargins.h"; sourceTree = ""; }; E69BA1971BB5D7D300078740 /* WPStyleGuide+ReadableMargins.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "WPStyleGuide+ReadableMargins.m"; sourceTree = ""; }; E69EF9D21BFA539F00ED0554 /* ReaderDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReaderDetailViewController.swift; sourceTree = ""; }; @@ -10261,6 +10262,7 @@ E125443B12BF5A7200D87A0A /* WordPress.xcdatamodeld */ = { isa = XCVersionGroup; children = ( + E699E530210BB719008ED8A7 /* WordPress 77.xcdatamodel */, 17F2A5D020ACC70D00F0BE10 /* WordPress 76.xcdatamodel */, 17E553B520910791000D3005 /* WordPress 75.xcdatamodel */, FFEECFFE20875329009B8CDB /* WordPress 74.xcdatamodel */, @@ -10338,7 +10340,7 @@ 8350E15911D28B4A00A7B073 /* WordPress.xcdatamodel */, E125443D12BF5A7200D87A0A /* WordPress 2.xcdatamodel */, ); - currentVersion = 17F2A5D020ACC70D00F0BE10 /* WordPress 76.xcdatamodel */; + currentVersion = E699E530210BB719008ED8A7 /* WordPress 77.xcdatamodel */; name = WordPress.xcdatamodeld; path = Classes/WordPress.xcdatamodeld; sourceTree = ""; From 620ddb3f7eb72e1d21d135c58ce149627d4d73a2 Mon Sep 17 00:00:00 2001 From: aerych Date: Sat, 28 Jul 2018 14:08:47 -0500 Subject: [PATCH 02/11] Bumps version of WordPressKit used. --- Podfile | 2 +- Podfile.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Podfile b/Podfile index b342e11f60b7..f3c0d7e45b55 100644 --- a/Podfile +++ b/Podfile @@ -23,7 +23,7 @@ def shared_with_networking_pods pod 'AFNetworking', '3.2.1' pod 'Alamofire', '4.7.2' pod 'wpxmlrpc', '0.8.3' - pod 'WordPressKit', :git => 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', :commit => 'c2ae16bbc3fb759e0684fc9e5642d52390d00285' + pod 'WordPressKit', '1.2.1' end def shared_test_pods diff --git a/Podfile.lock b/Podfile.lock index 3838ccf86d22..dd29de7e6f86 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -119,7 +119,7 @@ PODS: - WordPressShared (~> 1.0) - WordPressUI (~> 1.0) - wpxmlrpc (~> 0.8) - - WordPressKit (1.1): + - WordPressKit (1.3): - Alamofire (~> 4.7) - CocoaLumberjack (= 3.4.2) - NSObject-SafeExpectations (= 0.0.3) @@ -167,7 +167,7 @@ DEPENDENCIES: - WordPress-Aztec-iOS (= 1.0.0-beta.23) - WordPress-Editor-iOS (= 1.0.0-beta.23) - WordPressAuthenticator (= 1.0.4) - - WordPressKit (from `https://github.com/wordpress-mobile/WordPressKit-iOS.git`, commit `c2ae16bbc3fb759e0684fc9e5642d52390d00285`) + - WordPressKit (from `https://github.com/wordpress-mobile/WordPressKit-iOS.git`, commit `02527fe5e12f40c789feb1304feb166ed66972ac`) - WordPressShared (= 1.0.9) - WordPressUI (from `https://github.com/wordpress-mobile/WordPressUI-iOS.git`, commit `7a5b1a3fb44f62416fbc2e5f0de623b87b613aae`) - WPMediaPicker (= 1.1) @@ -214,7 +214,7 @@ EXTERNAL SOURCES: :git: https://github.com/Automattic/Automattic-Tracks-iOS.git :tag: 0.2.3 WordPressKit: - :commit: c2ae16bbc3fb759e0684fc9e5642d52390d00285 + :commit: 02527fe5e12f40c789feb1304feb166ed66972ac :git: https://github.com/wordpress-mobile/WordPressKit-iOS.git WordPressUI: :commit: 7a5b1a3fb44f62416fbc2e5f0de623b87b613aae @@ -225,7 +225,7 @@ CHECKOUT OPTIONS: :git: https://github.com/Automattic/Automattic-Tracks-iOS.git :tag: 0.2.3 WordPressKit: - :commit: c2ae16bbc3fb759e0684fc9e5642d52390d00285 + :commit: 02527fe5e12f40c789feb1304feb166ed66972ac :git: https://github.com/wordpress-mobile/WordPressKit-iOS.git WordPressUI: :commit: 7a5b1a3fb44f62416fbc2e5f0de623b87b613aae @@ -261,13 +261,13 @@ SPEC CHECKSUMS: WordPress-Aztec-iOS: f2cc5402915e6f62db9681a0872e308ba8c9850c WordPress-Editor-iOS: 4f46c2fa98f3017e9e39ad30ba9f03dbd6612ce4 WordPressAuthenticator: 2825f0c56f83a17470564dbec427991fa5cac5af - WordPressKit: a24baaa783c3a221f2d9a51c19318cbb27333373 + WordPressKit: 780d4eb5e656b049728966817f21d0c905bb5448 WordPressShared: e5ea8a1ed3329735e40bd6623830960f63dd10fd WordPressUI: af141587ec444f9af753a00605bd0d3f14d8d8a3 WPMediaPicker: 5cc9386a4720f906d8fb79c7c4090d216b9f2348 wpxmlrpc: bfc572f62ce7ee897f6f38b098d2ba08732ecef4 ZendeskSDK: 2cda4db2ba6b10ba89aeb8dddaa94e97c85946a0 -PODFILE CHECKSUM: d49dbb4ef6438960438d031aeea9531ce0dc843b +PODFILE CHECKSUM: 57d6dbcb3438f3d72b2982ba59c0129cb0fcee55 COCOAPODS: 1.5.3 From 68569675d5c4520be17c1f622e14eb54d927d785 Mon Sep 17 00:00:00 2001 From: aerych Date: Sat, 28 Jul 2018 14:09:42 -0500 Subject: [PATCH 03/11] Update PublicizeService.externalUsersOnly with value from remote. --- WordPress/Classes/Services/SharingService.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/Classes/Services/SharingService.swift b/WordPress/Classes/Services/SharingService.swift index a9069b1362ce..77a42704a5b7 100644 --- a/WordPress/Classes/Services/SharingService.swift +++ b/WordPress/Classes/Services/SharingService.swift @@ -358,6 +358,7 @@ open class SharingService: LocalCoreDataService { } pubService?.connectURL = remoteService.connectURL pubService?.detail = remoteService.detail + pubService?.externalUsersOnly = remoteService.externalUsersOnly pubService?.icon = remoteService.icon pubService?.jetpackModuleRequired = remoteService.jetpackModuleRequired pubService?.jetpackSupport = remoteService.jetpackSupport From 170fe82da2dc97fa45231a8514a1dfd73875737e Mon Sep 17 00:00:00 2001 From: aerych Date: Sat, 28 Jul 2018 14:11:15 -0500 Subject: [PATCH 04/11] Publicize: Wires up a no results view when there are no accounts. --- .../Classes/Models/PublicizeService.swift | 1 + .../Blog/SharingAccountViewController.swift | 29 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/WordPress/Classes/Models/PublicizeService.swift b/WordPress/Classes/Models/PublicizeService.swift index 543efd1a7059..a11ea153b9f8 100644 --- a/WordPress/Classes/Models/PublicizeService.swift +++ b/WordPress/Classes/Models/PublicizeService.swift @@ -3,6 +3,7 @@ import CoreData open class PublicizeService: NSManagedObject { @objc static let googlePlusServiceID = "google_plus" + @objc static let facebookServiceID = "facebook" @NSManaged open var connectURL: String @NSManaged open var detail: String diff --git a/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift b/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift index 012b600e97d6..0df26893787f 100644 --- a/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift @@ -72,6 +72,20 @@ import WordPressShared } + fileprivate func showNoResultsViewController() { + let title = NSLocalizedString("No Accounts Found", + comment:"Title of an error message. There were no third-party service accounts found to setup sharing.") + let message = NSLocalizedString("Sorry. The social service did not tell us which account could be used for sharing.", + comment:"An error message shown if a third-party social service does not specify any accounts that an be used with publicize sharing.") + + let noResultsViewController = NoResultsViewController.controllerWith(title: title, buttonTitle: nil, subtitle: message, image: nil, accessoryView: nil) + noResultsViewController.view.frame = view.frame + addChildViewController(noResultsViewController) + view.addSubview(noResultsViewController.view) + noResultsViewController.didMove(toParentViewController: self) + } + + // MARK: - View Model Wrangling @@ -84,6 +98,15 @@ import WordPressShared var connectedAccounts = [KeyringAccount]() var accounts = keyringAccountsFromKeyringConnections(keyringConnections) + if accounts.count == 0 { + if publicizeService.externalUsersOnly && publicizeService.serviceID == PublicizeService.facebookServiceID { + // TODO: Show Facebook notice + } else { + showNoResultsViewController() + } + return ImmuTable(sections: []) + } + // Filter out connected accounts into a different Array for (idx, acct) in accounts.enumerated() { if accountIsConnected(acct) { @@ -196,7 +219,11 @@ import WordPressShared for connection in connections { let acct = KeyringAccount(name: connection.externalDisplay, externalID: nil, externalIDForConnection: connection.externalID, keyringConnection: connection) - accounts.append(acct) + + // Do not include the service if it only supports external users. + if !publicizeService.externalUsersOnly { + accounts.append(acct) + } for externalUser in connection.additionalExternalUsers { let acct = KeyringAccount(name: externalUser.externalName, externalID: externalUser.externalID, externalIDForConnection: externalUser.externalID, keyringConnection: connection) From 5a35eb51e2d63c71bc953769b2baf6dd1e3bbd85 Mon Sep 17 00:00:00 2001 From: aerych Date: Sat, 28 Jul 2018 15:52:44 -0500 Subject: [PATCH 05/11] Publicize: Show facebook prompt when no pages to share to. --- .../Blog/SharingAccountViewController.swift | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift b/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift index 0df26893787f..893e3e28a448 100644 --- a/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift @@ -12,6 +12,15 @@ import WordPressShared @objc var immutableHandler: ImmuTableViewHandler! @objc var delegate: SharingAccountSelectionDelegate? + lazy var noResultsViewController: NoResultsViewController = { + let controller = NoResultsViewController.controller() + controller.view.frame = view.frame + addChildViewController(controller) + view.addSubview(controller.view) + controller.didMove(toParentViewController: self) + return controller + }() + // MARK: - Lifecycle Methods @@ -77,12 +86,17 @@ import WordPressShared comment:"Title of an error message. There were no third-party service accounts found to setup sharing.") let message = NSLocalizedString("Sorry. The social service did not tell us which account could be used for sharing.", comment:"An error message shown if a third-party social service does not specify any accounts that an be used with publicize sharing.") + noResultsViewController.configure(title: title, buttonTitle: nil, subtitle: message, image: nil, accessoryView: nil) + } + - let noResultsViewController = NoResultsViewController.controllerWith(title: title, buttonTitle: nil, subtitle: message, image: nil, accessoryView: nil) - noResultsViewController.view.frame = view.frame - addChildViewController(noResultsViewController) - view.addSubview(noResultsViewController.view) - noResultsViewController.didMove(toParentViewController: self) + fileprivate func showFacebookNotice() { + let message = NSLocalizedString("The Facebook connection could not be made because this account does not have access to any pages. Facebook supports sharing connections to Facebook Pages, but not to Facebook Profiles.", + comment: "Error message shown to a user who is trying to share to Facebook but does not have any available Facebook Pages.") + + let buttonTitle = NSLocalizedString("Learn more", comment: "A button title.") + noResultsViewController.configure(title: "", buttonTitle: buttonTitle, subtitle: message, image: nil, accessoryView: nil) + noResultsViewController.delegate = self } @@ -100,7 +114,7 @@ import WordPressShared if accounts.count == 0 { if publicizeService.externalUsersOnly && publicizeService.serviceID == PublicizeService.facebookServiceID { - // TODO: Show Facebook notice + showFacebookNotice() } else { showNoResultsViewController() } @@ -310,3 +324,14 @@ import WordPressShared func didDismissSharingAccountViewController(_ controller: SharingAccountViewController) func sharingAccountViewController(_ controller: SharingAccountViewController, selectedKeyringConnection keyringConnection: KeyringConnection, externalID: String?) } + + +extension SharingAccountViewController: NoResultsViewControllerDelegate +{ + func actionButtonPressed() { + if let url = URL(string: "https://en.support.wordpress.com/publicize/#facebook-pages") { + UIApplication.shared.open(url) + } + dismiss(animated: true, completion: nil) + } +} From 55eb94350839c7eeb61d5d7fcd66f1e8407e2b23 Mon Sep 17 00:00:00 2001 From: aerych Date: Sat, 28 Jul 2018 15:53:30 -0500 Subject: [PATCH 06/11] Publicize: Handle status. --- WordPress/Classes/Models/PublicizeConnection.swift | 4 ++++ .../ViewRelated/Blog/SharingConnectionsViewController.m | 2 +- WordPress/Classes/ViewRelated/Blog/SharingViewController.m | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/WordPress/Classes/Models/PublicizeConnection.swift b/WordPress/Classes/Models/PublicizeConnection.swift index bcd11ed39db2..4ba0a2f773c5 100644 --- a/WordPress/Classes/Models/PublicizeConnection.swift +++ b/WordPress/Classes/Models/PublicizeConnection.swift @@ -28,4 +28,8 @@ open class PublicizeConnection: NSManagedObject { @objc open func isBroken() -> Bool { return status == "broken" } + + @objc open func mustDisconnect() -> Bool { + return status == "must-disconnect" + } } diff --git a/WordPress/Classes/ViewRelated/Blog/SharingConnectionsViewController.m b/WordPress/Classes/ViewRelated/Blog/SharingConnectionsViewController.m index 58cf3b33084e..cb5a1e9637f0 100644 --- a/WordPress/Classes/ViewRelated/Blog/SharingConnectionsViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/SharingConnectionsViewController.m @@ -196,7 +196,7 @@ - (void)configurePublicizeCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath PublicizeConnection *connection = [[self connectionsForService] objectAtIndex:indexPath.row]; cell.textLabel.text = connection.externalDisplay; - if ([connection isBroken]) { + if ([connection isBroken] || [connection mustDisconnect]) { cell.accessoryView = [WPStyleGuide sharingCellWarningAccessoryImageView]; } } diff --git a/WordPress/Classes/ViewRelated/Blog/SharingViewController.m b/WordPress/Classes/ViewRelated/Blog/SharingViewController.m index 3c23e9762b49..0c01be5e69bd 100644 --- a/WordPress/Classes/ViewRelated/Blog/SharingViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/SharingViewController.m @@ -193,7 +193,7 @@ - (void)configurePublicizeCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath // Check if any of the connections are broken. for (PublicizeConnection *pubConn in connections) { - if ([pubConn isBroken]) { + if ([pubConn isBroken] || [pubConn mustDisconnect]) { cell.accessoryView = [WPStyleGuide sharingCellWarningAccessoryImageView]; break; } From e84c448195d6952147ad843044e998460c816598 Mon Sep 17 00:00:00 2001 From: aerych Date: Sat, 28 Jul 2018 16:47:17 -0500 Subject: [PATCH 07/11] Publicize: Handle must-disconnect facebook connections. --- .../Blog/SharingDetailViewController.m | 54 ++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Blog/SharingDetailViewController.m b/WordPress/Classes/ViewRelated/Blog/SharingDetailViewController.m index b99c81fca7f3..20c2ad4d7802 100644 --- a/WordPress/Classes/ViewRelated/Blog/SharingDetailViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/SharingDetailViewController.m @@ -60,6 +60,17 @@ - (void)viewDidLoad #pragma mark - Instance Methods +- (BOOL)mustDisconnectFacebook +{ + return [self.publicizeConnection mustDisconnect] && [[self.publicizeConnection service] isEqualToString: [PublicizeService facebookServiceID]]; +} + +- (void)openFacebookFAQ +{ + NSURL *url = [NSURL URLWithString:@"https://en.blog.wordpress.com/2018/07/23/sharing-options-from-wordpress-com-to-facebook-are-changing/"]; + [[UIApplication sharedApplication] openURL:url options:[NSDictionary new] completionHandler:nil]; +} + - (NSManagedObjectContext *)managedObjectContext { return self.blog.managedObjectContext; @@ -70,7 +81,7 @@ - (NSManagedObjectContext *)managedObjectContext - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - if ([self.publicizeConnection isBroken]) { + if ([self.publicizeConnection isBroken] || [self mustDisconnectFacebook]) { return 3; } @@ -96,10 +107,19 @@ - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInte if (section == 0) { return NSLocalizedString(@"Allow this connection to be used by all admins and users of your site.", @""); } - if (section == 1 && [self.publicizeConnection isBroken]) { - NSString *title = NSLocalizedString(@"There is an issue connecting to %@. Reconnect to continue publicizing.", @"Informs the user about an issue connecting to the third-party sharing service. The `%@` is a placeholder for the service name."); - return [NSString stringWithFormat:title, self.publicizeConnection.label]; + + if (section == 1) { + if ([self mustDisconnectFacebook]) { + NSString *title = NSLocalizedString(@"As of August 1, 2018, Facebook no longer allows direct sharing of posts to Facebook Profiles. Connections to Facebook Pages remain unchanged.", @"Message shown to users who have an old publicize connection to a facebook profile."); + return [NSString stringWithFormat:title, self.publicizeConnection.label]; + } + + if ([self.publicizeConnection isBroken]) { + NSString *title = NSLocalizedString(@"There is an issue connecting to %@. Reconnect to continue publicizing.", @"Informs the user about an issue connecting to the third-party sharing service. The `%@` is a placeholder for the service name."); + return [NSString stringWithFormat:title, self.publicizeConnection.label]; + } } + return nil; } @@ -119,11 +139,18 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N if (indexPath.section == 0) { cell = [self switchTableViewCell]; - } else if (indexPath.section == 1 && [self.publicizeConnection isBroken]) { - cell.textLabel.text = NSLocalizedString(@"Reconnect", @"Verb. Text label. Tapping attempts to reconnect a third-party sharing service to the user's blog."); - [WPStyleGuide configureTableViewActionCell:cell]; - cell.textLabel.textAlignment = NSTextAlignmentCenter; - cell.textLabel.textColor = [WPStyleGuide jazzyOrange]; + } else if (indexPath.section == 1) { + if ([self.publicizeConnection isBroken]) { + cell.textLabel.text = NSLocalizedString(@"Reconnect", @"Verb. Text label. Tapping attempts to reconnect a third-party sharing service to the user's blog."); + [WPStyleGuide configureTableViewActionCell:cell]; + cell.textLabel.textAlignment = NSTextAlignmentCenter; + cell.textLabel.textColor = [WPStyleGuide jazzyOrange]; + } else if ([self mustDisconnectFacebook]) { + cell.textLabel.text = NSLocalizedString(@"Learn More", @"Title of a button. Tapping allows the user to learn more about the specific error."); + [WPStyleGuide configureTableViewActionCell:cell]; + cell.textLabel.textAlignment = NSTextAlignmentCenter; + cell.textLabel.textColor = [WPStyleGuide wordPressBlue]; + } } else { cell.textLabel.text = NSLocalizedString(@"Disconnect", @"Verb. Text label. Tapping disconnects a third-party sharing service from the user's blog."); @@ -137,9 +164,12 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; - if (indexPath.section == 1 && [self.publicizeConnection isBroken]) { - [self reconnectPublicizeConnection]; - + if (indexPath.section == 1) { + if ([self.publicizeConnection isBroken]) { + [self reconnectPublicizeConnection]; + } else if ([self mustDisconnectFacebook]) { + [self openFacebookFAQ]; + } } else { [self promptToConfirmDisconnect]; } From 658f604b985d0f85cf8f13c60648a1654087f3d0 Mon Sep 17 00:00:00 2001 From: aerych Date: Sat, 28 Jul 2018 17:05:30 -0500 Subject: [PATCH 08/11] Fix whitespace. Shut up hound. --- .../ViewRelated/Blog/SharingAccountViewController.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift b/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift index 893e3e28a448..7775430eff46 100644 --- a/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift @@ -83,9 +83,9 @@ import WordPressShared fileprivate func showNoResultsViewController() { let title = NSLocalizedString("No Accounts Found", - comment:"Title of an error message. There were no third-party service accounts found to setup sharing.") + comment: "Title of an error message. There were no third-party service accounts found to setup sharing.") let message = NSLocalizedString("Sorry. The social service did not tell us which account could be used for sharing.", - comment:"An error message shown if a third-party social service does not specify any accounts that an be used with publicize sharing.") + comment: "An error message shown if a third-party social service does not specify any accounts that an be used with publicize sharing.") noResultsViewController.configure(title: title, buttonTitle: nil, subtitle: message, image: nil, accessoryView: nil) } @@ -326,8 +326,7 @@ import WordPressShared } -extension SharingAccountViewController: NoResultsViewControllerDelegate -{ +extension SharingAccountViewController: NoResultsViewControllerDelegate { func actionButtonPressed() { if let url = URL(string: "https://en.support.wordpress.com/publicize/#facebook-pages") { UIApplication.shared.open(url) From 96dc32c3402de141fec50dac8cff9773cdaafc90 Mon Sep 17 00:00:00 2001 From: aerych Date: Sun, 29 Jul 2018 23:46:10 -0500 Subject: [PATCH 09/11] Publicize: Adds helper methods to model. --- WordPress/Classes/Models/PublicizeConnection.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/WordPress/Classes/Models/PublicizeConnection.swift b/WordPress/Classes/Models/PublicizeConnection.swift index 4ba0a2f773c5..cf0be9c6db1a 100644 --- a/WordPress/Classes/Models/PublicizeConnection.swift +++ b/WordPress/Classes/Models/PublicizeConnection.swift @@ -32,4 +32,12 @@ open class PublicizeConnection: NSManagedObject { @objc open func mustDisconnect() -> Bool { return status == "must-disconnect" } + + @objc open func requiresUserAction() -> Bool { + return isBroken() || mustDisconnect() + } + + @objc open func mustDisconnectFacebook() -> Bool { + return mustDisconnect() && service == PublicizeService.facebookServiceID + } } From ba54dd7b51676fcc025b622d4f3f5baf693f23fd Mon Sep 17 00:00:00 2001 From: aerych Date: Sun, 29 Jul 2018 23:47:08 -0500 Subject: [PATCH 10/11] Publicize: Changes from code review. --- .../Blog/SharingAccountViewController.swift | 4 +- .../Blog/SharingConnectionsViewController.m | 2 +- .../Blog/SharingDetailViewController.m | 77 +++++++++++-------- .../ViewRelated/Blog/SharingViewController.m | 2 +- 4 files changed, 51 insertions(+), 34 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift b/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift index 7775430eff46..28dddb932b8c 100644 --- a/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/SharingAccountViewController.swift @@ -12,7 +12,7 @@ import WordPressShared @objc var immutableHandler: ImmuTableViewHandler! @objc var delegate: SharingAccountSelectionDelegate? - lazy var noResultsViewController: NoResultsViewController = { + fileprivate lazy var noResultsViewController: NoResultsViewController = { let controller = NoResultsViewController.controller() controller.view.frame = view.frame addChildViewController(controller) @@ -113,7 +113,7 @@ import WordPressShared var accounts = keyringAccountsFromKeyringConnections(keyringConnections) if accounts.count == 0 { - if publicizeService.externalUsersOnly && publicizeService.serviceID == PublicizeService.facebookServiceID { + if publicizeService.serviceID == PublicizeService.facebookServiceID { showFacebookNotice() } else { showNoResultsViewController() diff --git a/WordPress/Classes/ViewRelated/Blog/SharingConnectionsViewController.m b/WordPress/Classes/ViewRelated/Blog/SharingConnectionsViewController.m index cb5a1e9637f0..a4eecdc249be 100644 --- a/WordPress/Classes/ViewRelated/Blog/SharingConnectionsViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/SharingConnectionsViewController.m @@ -196,7 +196,7 @@ - (void)configurePublicizeCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath PublicizeConnection *connection = [[self connectionsForService] objectAtIndex:indexPath.row]; cell.textLabel.text = connection.externalDisplay; - if ([connection isBroken] || [connection mustDisconnect]) { + if ([connection requiresUserAction]) { cell.accessoryView = [WPStyleGuide sharingCellWarningAccessoryImageView]; } } diff --git a/WordPress/Classes/ViewRelated/Blog/SharingDetailViewController.m b/WordPress/Classes/ViewRelated/Blog/SharingDetailViewController.m index 20c2ad4d7802..922ced0a20fc 100644 --- a/WordPress/Classes/ViewRelated/Blog/SharingDetailViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/SharingDetailViewController.m @@ -60,17 +60,46 @@ - (void)viewDidLoad #pragma mark - Instance Methods -- (BOOL)mustDisconnectFacebook -{ - return [self.publicizeConnection mustDisconnect] && [[self.publicizeConnection service] isEqualToString: [PublicizeService facebookServiceID]]; -} - - (void)openFacebookFAQ { NSURL *url = [NSURL URLWithString:@"https://en.blog.wordpress.com/2018/07/23/sharing-options-from-wordpress-com-to-facebook-are-changing/"]; [[UIApplication sharedApplication] openURL:url options:[NSDictionary new] completionHandler:nil]; } +- (NSString *)textForFacebookFooter +{ + NSString *title = NSLocalizedString(@"As of August 1, 2018, Facebook no longer allows direct sharing of posts to Facebook Profiles. Connections to Facebook Pages remain unchanged.", @"Message shown to users who have an old publicize connection to a facebook profile."); + return [NSString stringWithFormat:title, self.publicizeConnection.label]; +} + +- (NSString *)textForBrokenConnectionFooter +{ + NSString *title = NSLocalizedString(@"There is an issue connecting to %@. Reconnect to continue publicizing.", @"Informs the user about an issue connecting to the third-party sharing service. The `%@` is a placeholder for the service name."); + return [NSString stringWithFormat:title, self.publicizeConnection.label]; +} + +- (void)configureReconnectCell: (UITableViewCell *)cell +{ + cell.textLabel.text = NSLocalizedString(@"Reconnect", @"Verb. Text label. Tapping attempts to reconnect a third-party sharing service to the user's blog."); + [WPStyleGuide configureTableViewActionCell:cell]; + cell.textLabel.textAlignment = NSTextAlignmentCenter; + cell.textLabel.textColor = [WPStyleGuide jazzyOrange]; +} + +- (void)configureLearnMoreCell: (UITableViewCell *)cell +{ + cell.textLabel.text = NSLocalizedString(@"Learn More", @"Title of a button. Tapping allows the user to learn more about the specific error."); + [WPStyleGuide configureTableViewActionCell:cell]; + cell.textLabel.textAlignment = NSTextAlignmentCenter; + cell.textLabel.textColor = [WPStyleGuide wordPressBlue]; +} + +- (void)configureDisconnectCell: (UITableViewCell *)cell +{ + cell.textLabel.text = NSLocalizedString(@"Disconnect", @"Verb. Text label. Tapping disconnects a third-party sharing service from the user's blog."); + [WPStyleGuide configureTableViewDestructiveActionCell:cell]; +} + - (NSManagedObjectContext *)managedObjectContext { return self.blog.managedObjectContext; @@ -81,7 +110,7 @@ - (NSManagedObjectContext *)managedObjectContext - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - if ([self.publicizeConnection isBroken] || [self mustDisconnectFacebook]) { + if ([self.publicizeConnection requiresUserAction]) { return 3; } @@ -109,14 +138,12 @@ - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInte } if (section == 1) { - if ([self mustDisconnectFacebook]) { - NSString *title = NSLocalizedString(@"As of August 1, 2018, Facebook no longer allows direct sharing of posts to Facebook Profiles. Connections to Facebook Pages remain unchanged.", @"Message shown to users who have an old publicize connection to a facebook profile."); - return [NSString stringWithFormat:title, self.publicizeConnection.label]; + if ([self.publicizeConnection mustDisconnectFacebook]) { + return [self textForFacebookFooter]; } if ([self.publicizeConnection isBroken]) { - NSString *title = NSLocalizedString(@"There is an issue connecting to %@. Reconnect to continue publicizing.", @"Informs the user about an issue connecting to the third-party sharing service. The `%@` is a placeholder for the service name."); - return [NSString stringWithFormat:title, self.publicizeConnection.label]; + return [self textForBrokenConnectionFooter]; } } @@ -139,22 +166,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N if (indexPath.section == 0) { cell = [self switchTableViewCell]; - } else if (indexPath.section == 1) { - if ([self.publicizeConnection isBroken]) { - cell.textLabel.text = NSLocalizedString(@"Reconnect", @"Verb. Text label. Tapping attempts to reconnect a third-party sharing service to the user's blog."); - [WPStyleGuide configureTableViewActionCell:cell]; - cell.textLabel.textAlignment = NSTextAlignmentCenter; - cell.textLabel.textColor = [WPStyleGuide jazzyOrange]; - } else if ([self mustDisconnectFacebook]) { - cell.textLabel.text = NSLocalizedString(@"Learn More", @"Title of a button. Tapping allows the user to learn more about the specific error."); - [WPStyleGuide configureTableViewActionCell:cell]; - cell.textLabel.textAlignment = NSTextAlignmentCenter; - cell.textLabel.textColor = [WPStyleGuide wordPressBlue]; - } + } else if (indexPath.section == 1 && [self.publicizeConnection isBroken]) { + [self configureReconnectCell:cell]; + + } else if (indexPath.section == 1 && [self.publicizeConnection mustDisconnectFacebook]) { + [self configureLearnMoreCell:cell]; } else { - cell.textLabel.text = NSLocalizedString(@"Disconnect", @"Verb. Text label. Tapping disconnects a third-party sharing service from the user's blog."); - [WPStyleGuide configureTableViewDestructiveActionCell:cell]; + [self configureDisconnectCell:cell]; } return cell; @@ -164,12 +183,10 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; - if (indexPath.section == 1) { - if ([self.publicizeConnection isBroken]) { - [self reconnectPublicizeConnection]; - } else if ([self mustDisconnectFacebook]) { + if (indexPath.section == 1 && [self.publicizeConnection isBroken]) { + [self reconnectPublicizeConnection]; + } else if (indexPath.section == 1 && [self.publicizeConnection mustDisconnectFacebook]) { [self openFacebookFAQ]; - } } else { [self promptToConfirmDisconnect]; } diff --git a/WordPress/Classes/ViewRelated/Blog/SharingViewController.m b/WordPress/Classes/ViewRelated/Blog/SharingViewController.m index 0c01be5e69bd..e4307cccd5ba 100644 --- a/WordPress/Classes/ViewRelated/Blog/SharingViewController.m +++ b/WordPress/Classes/ViewRelated/Blog/SharingViewController.m @@ -193,7 +193,7 @@ - (void)configurePublicizeCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath // Check if any of the connections are broken. for (PublicizeConnection *pubConn in connections) { - if ([pubConn isBroken] || [pubConn mustDisconnect]) { + if ([pubConn requiresUserAction]) { cell.accessoryView = [WPStyleGuide sharingCellWarningAccessoryImageView]; break; } From a79505e9b6c1a986eab0cf03a13d57f3a46f4441 Mon Sep 17 00:00:00 2001 From: aerych Date: Mon, 30 Jul 2018 03:35:03 -0500 Subject: [PATCH 11/11] Fixes Podfile.lock --- Podfile.lock | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index dd29de7e6f86..4aeec506ab30 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -119,7 +119,7 @@ PODS: - WordPressShared (~> 1.0) - WordPressUI (~> 1.0) - wpxmlrpc (~> 0.8) - - WordPressKit (1.3): + - WordPressKit (1.2.1): - Alamofire (~> 4.7) - CocoaLumberjack (= 3.4.2) - NSObject-SafeExpectations (= 0.0.3) @@ -167,7 +167,7 @@ DEPENDENCIES: - WordPress-Aztec-iOS (= 1.0.0-beta.23) - WordPress-Editor-iOS (= 1.0.0-beta.23) - WordPressAuthenticator (= 1.0.4) - - WordPressKit (from `https://github.com/wordpress-mobile/WordPressKit-iOS.git`, commit `02527fe5e12f40c789feb1304feb166ed66972ac`) + - WordPressKit (= 1.2.1) - WordPressShared (= 1.0.9) - WordPressUI (from `https://github.com/wordpress-mobile/WordPressUI-iOS.git`, commit `7a5b1a3fb44f62416fbc2e5f0de623b87b613aae`) - WPMediaPicker (= 1.1) @@ -204,6 +204,7 @@ SPEC REPOS: - WordPress-Aztec-iOS - WordPress-Editor-iOS - WordPressAuthenticator + - WordPressKit - WordPressShared - WPMediaPicker - wpxmlrpc @@ -213,9 +214,6 @@ EXTERNAL SOURCES: Automattic-Tracks-iOS: :git: https://github.com/Automattic/Automattic-Tracks-iOS.git :tag: 0.2.3 - WordPressKit: - :commit: 02527fe5e12f40c789feb1304feb166ed66972ac - :git: https://github.com/wordpress-mobile/WordPressKit-iOS.git WordPressUI: :commit: 7a5b1a3fb44f62416fbc2e5f0de623b87b613aae :git: https://github.com/wordpress-mobile/WordPressUI-iOS.git @@ -224,9 +222,6 @@ CHECKOUT OPTIONS: Automattic-Tracks-iOS: :git: https://github.com/Automattic/Automattic-Tracks-iOS.git :tag: 0.2.3 - WordPressKit: - :commit: 02527fe5e12f40c789feb1304feb166ed66972ac - :git: https://github.com/wordpress-mobile/WordPressKit-iOS.git WordPressUI: :commit: 7a5b1a3fb44f62416fbc2e5f0de623b87b613aae :git: https://github.com/wordpress-mobile/WordPressUI-iOS.git @@ -261,13 +256,13 @@ SPEC CHECKSUMS: WordPress-Aztec-iOS: f2cc5402915e6f62db9681a0872e308ba8c9850c WordPress-Editor-iOS: 4f46c2fa98f3017e9e39ad30ba9f03dbd6612ce4 WordPressAuthenticator: 2825f0c56f83a17470564dbec427991fa5cac5af - WordPressKit: 780d4eb5e656b049728966817f21d0c905bb5448 + WordPressKit: a4a3849684f631a3abf579f6d3f15a32677cbb30 WordPressShared: e5ea8a1ed3329735e40bd6623830960f63dd10fd WordPressUI: af141587ec444f9af753a00605bd0d3f14d8d8a3 WPMediaPicker: 5cc9386a4720f906d8fb79c7c4090d216b9f2348 wpxmlrpc: bfc572f62ce7ee897f6f38b098d2ba08732ecef4 ZendeskSDK: 2cda4db2ba6b10ba89aeb8dddaa94e97c85946a0 -PODFILE CHECKSUM: 57d6dbcb3438f3d72b2982ba59c0129cb0fcee55 +PODFILE CHECKSUM: 6c257291bab7089dda9372c0fc53feda5f8b5f3a COCOAPODS: 1.5.3