Merge pull request #446 from vincode-io/issue-276

Added subject to email sharing and light boxed the social media share…
This commit is contained in:
Brent Simmons 2018-09-08 11:45:22 -07:00 committed by GitHub
commit 1c9d970efd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 2 deletions

View File

@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
519B8D332143397200FA689C /* SharingServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519B8D322143397200FA689C /* SharingServiceDelegate.swift */; };
6581C73820CED60100F4AD34 /* SafariExtensionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6581C73720CED60100F4AD34 /* SafariExtensionHandler.swift */; };
6581C73A20CED60100F4AD34 /* SafariExtensionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6581C73920CED60100F4AD34 /* SafariExtensionViewController.swift */; };
6581C73D20CED60100F4AD34 /* SafariExtensionViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6581C73B20CED60100F4AD34 /* SafariExtensionViewController.xib */; };
@ -478,6 +479,7 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
519B8D322143397200FA689C /* SharingServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingServiceDelegate.swift; sourceTree = "<group>"; };
6581C73320CED60000F4AD34 /* Subscribe to Feed.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Subscribe to Feed.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
6581C73420CED60100F4AD34 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
6581C73720CED60100F4AD34 /* SafariExtensionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariExtensionHandler.swift; sourceTree = "<group>"; };
@ -828,6 +830,7 @@
842E45E21ED8C681000A8B52 /* KeyboardDelegateProtocol.swift */,
849A975D1ED9EB72007D329B /* MainWindowController.swift */,
849EE71E20391DF20082A1EA /* MainWindowToolbarDelegate.swift */,
519B8D322143397200FA689C /* SharingServiceDelegate.swift */,
849EE72020391F560082A1EA /* SharingServicePickerDelegate.swift */,
842E45E41ED8C6B7000A8B52 /* MainWindowSplitView.swift */,
844B5B6B1FEA224B00C7C76A /* Keyboard */,
@ -1949,6 +1952,7 @@
84A1500520048DDF0046AD9A /* SendToMarsEditCommand.swift in Sources */,
D5907DB22004BB37005947E5 /* ScriptingObjectContainer.swift in Sources */,
849A978A1ED9ECEF007D329B /* ArticleStylesManager.swift in Sources */,
519B8D332143397200FA689C /* SharingServiceDelegate.swift in Sources */,
84E8E0DB202EC49300562D8F /* TimelineViewController+ContextualMenus.swift in Sources */,
849A97791ED9EC04007D329B /* TimelineStringUtilities.swift in Sources */,
84E185C3203BB12600F69BFA /* MultilineTextFieldSizer.swift in Sources */,

View File

@ -14,7 +14,7 @@ import RSCore
class MainWindowController : NSWindowController, NSUserInterfaceValidations {
@IBOutlet var toolbarDelegate: MainWindowToolbarDelegate?
private let sharingServicePickerDelegate = SharingServicePickerDelegate()
private var sharingServicePickerDelegate: NSSharingServicePickerDelegate?
private let windowAutosaveName = NSWindow.FrameAutosaveName(rawValue: "MainWindow")
static var didPositionWindowOnFirstRun = false
@ -39,6 +39,8 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
super.windowDidLoad()
sharingServicePickerDelegate = SharingServicePickerDelegate(self.window)
if !AppDefaults.shared.showTitleOnMainWindow {
window?.titleVisibility = .hidden
}

View File

@ -0,0 +1,42 @@
//
// SharingServiceDelegate.swift
// NetNewsWire
//
// Created by Maurice Parker on 9/7/18.
// Copyright © 2018 Ranchero Software. All rights reserved.
//
import AppKit
@objc final class SharingServiceDelegate: NSObject, NSSharingServiceDelegate {
weak var window: NSWindow?
init(_ window: NSWindow?) {
self.window = window
}
func sharingService(_ sharingService: NSSharingService, willShareItems items: [Any]) {
var subject = ""
for (index, item) in items.enumerated() {
guard let writer = item as? ArticlePasteboardWriter,
let title = writer.article.title else {
continue
}
subject += index != 0 ? ", \(title)" : title
}
sharingService.subject = subject
}
func sharingService(_ sharingService: NSSharingService, sourceWindowForShareItems items: [Any], sharingContentScope: UnsafeMutablePointer<NSSharingService.SharingContentScope>) -> NSWindow? {
return window
}
}

View File

@ -9,10 +9,21 @@
import AppKit
@objc final class SharingServicePickerDelegate: NSObject, NSSharingServicePickerDelegate {
private let sharingServiceDelegate: SharingServiceDelegate
init(_ window: NSWindow?) {
sharingServiceDelegate = SharingServiceDelegate(window)
}
func sharingServicePicker(_ sharingServicePicker: NSSharingServicePicker, sharingServicesForItems items: [Any], proposedSharingServices proposedServices: [NSSharingService]) -> [NSSharingService] {
return proposedServices + SharingServicePickerDelegate.customSharingServices(for: items)
}
func sharingServicePicker(_ sharingServicePicker: NSSharingServicePicker, delegateFor sharingService: NSSharingService) -> NSSharingServiceDelegate? {
return sharingServiceDelegate
}
static func customSharingServices(for items: [Any]) -> [NSSharingService] {