Merge pull request #3186 from danielpunkass/default-feed-handler
Hopefully finishing up the fixes for handling the "open in default browser" preference
This commit is contained in:
commit
e3f066aaf5
|
@ -107,12 +107,24 @@ final class AppDefaults {
|
|||
}
|
||||
}
|
||||
|
||||
// Special case for this default: store/retrieve it from the shared app group
|
||||
// defaults, so that it can be resolved by the Safari App Extension.
|
||||
var subscribeToFeedDefaults: UserDefaults {
|
||||
if let appGroupID = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as? String,
|
||||
let appGroupDefaults = UserDefaults(suiteName: appGroupID) {
|
||||
return appGroupDefaults
|
||||
}
|
||||
else {
|
||||
return UserDefaults.standard
|
||||
}
|
||||
}
|
||||
|
||||
var subscribeToFeedsInDefaultBrowser: Bool {
|
||||
get {
|
||||
return AppDefaults.bool(for: Key.subscribeToFeedsInDefaultBrowser)
|
||||
return subscribeToFeedDefaults.bool(forKey: Key.subscribeToFeedsInDefaultBrowser)
|
||||
}
|
||||
set {
|
||||
AppDefaults.setBool(for: Key.subscribeToFeedsInDefaultBrowser, newValue)
|
||||
subscribeToFeedDefaults.set(newValue, forKey: Key.subscribeToFeedsInDefaultBrowser)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,7 +309,6 @@ final class AppDefaults {
|
|||
Key.detailFontSize: FontSize.medium.rawValue,
|
||||
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,
|
||||
Key.timelineGroupByFeed: false,
|
||||
Key.subscribeToFeedsInDefaultBrowser: false,
|
||||
"NSScrollViewShouldScrollUnderTitlebar": false,
|
||||
Key.refreshInterval: RefreshInterval.everyHour.rawValue,
|
||||
Key.showDebugMenu: showDebugMenu]
|
||||
|
|
|
@ -190,7 +190,7 @@
|
|||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="mAF-gO-1PI" name="value" keyPath="values.subscribeToFeedsInDefaultBrowser" id="rgT-1E-AoD">
|
||||
<binding destination="iuH-lz-18x" name="value" keyPath="openFeedsInDefaultNewsReader" id="l1B-rk-qfE">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">NSNegateBoolean</string>
|
||||
</dictionary>
|
||||
|
@ -204,7 +204,7 @@
|
|||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="mAF-gO-1PI" name="value" keyPath="values.subscribeToFeedsInDefaultBrowser" id="Dnc-co-ppt"/>
|
||||
<binding destination="iuH-lz-18x" name="value" keyPath="openFeedsInDefaultNewsReader" id="QZ4-W8-rPi"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
|
|
|
@ -126,4 +126,12 @@ private extension GeneralPreferencesViewController {
|
|||
}
|
||||
}
|
||||
|
||||
@objc var openFeedsInDefaultNewsReader: Bool {
|
||||
get {
|
||||
return AppDefaults.shared.subscribeToFeedsInDefaultBrowser
|
||||
}
|
||||
set {
|
||||
AppDefaults.shared.subscribeToFeedsInDefaultBrowser = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
<string>Subscribe to Feed</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>AppGroup</key>
|
||||
<string>group.$(ORGANIZATION_IDENTIFIER).NetNewsWire-Evergreen</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
|
|
|
@ -45,15 +45,11 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
|||
if var feedURLString = userInfo?["url"] as? String {
|
||||
var openInDefaultBrowser = false
|
||||
|
||||
// Ask for the user default from NetNewsWire's defaults to determine whether to open the feed URL
|
||||
// using whatever the system configured default is, or to always hard-code it to NetNewsWire itself.
|
||||
if let pluginBundleID = Bundle.main.bundleIdentifier {
|
||||
// By convention we assume that our bundle ID will always be the same as the host app's, with
|
||||
// the addition of ".Subscribe-to-Feed".
|
||||
let hostAppBundleID = pluginBundleID.replacingOccurrences(of: ".Subscribe-to-Feed", with: "")
|
||||
|
||||
if let sharedDefaults = UserDefaults(suiteName: hostAppBundleID) {
|
||||
openInDefaultBrowser = sharedDefaults.bool(forKey: "subscribeToFeedsInDefaultBrowser")
|
||||
// Ask for the user's choice for whether to open the feed URL using whatever the system
|
||||
// configured default is, or to always hard-code it to have NetNewsWire handle it itself.
|
||||
if let appGroupID = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as? String {
|
||||
if let groupDefaults = UserDefaults(suiteName: appGroupID) {
|
||||
openInDefaultBrowser = groupDefaults.bool(forKey: "subscribeToFeedsInDefaultBrowser")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,10 +40,17 @@ extension AppDelegate : AppDelegateAppleEvents {
|
|||
|
||||
@objc func getURL(_ event: NSAppleEventDescriptor, _ withReplyEvent: NSAppleEventDescriptor) {
|
||||
|
||||
guard let urlString = event.paramDescriptor(forKeyword: keyDirectObject)?.stringValue else {
|
||||
guard var urlString = event.paramDescriptor(forKeyword: keyDirectObject)?.stringValue else {
|
||||
return
|
||||
}
|
||||
|
||||
// Special case URL with specific scheme handler x-netnewswire-feed: intended to ensure we open
|
||||
// it regardless of which news reader may be set as the default
|
||||
let nnwScheme = "x-netnewswire-feed:"
|
||||
if urlString.hasPrefix(nnwScheme) {
|
||||
urlString = urlString.replacingOccurrences(of: nnwScheme, with: "feed:")
|
||||
}
|
||||
|
||||
let normalizedURLString = urlString.normalizedURL
|
||||
if !normalizedURLString.mayBeURL {
|
||||
return
|
||||
|
|
|
@ -1279,13 +1279,6 @@
|
|||
remoteGlobalIDString = 6581C73220CED60000F4AD34;
|
||||
remoteInfo = "Subscribe to Feed";
|
||||
};
|
||||
65ED41C6235E615E0081F399 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 849C64581ED37A5D003D8FC0 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 65ED4090235DEF770081F399;
|
||||
remoteInfo = "Subscribe to Feed MAS";
|
||||
};
|
||||
849C64721ED37A5D003D8FC0 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 849C64581ED37A5D003D8FC0 /* Project object */;
|
||||
|
@ -4075,7 +4068,6 @@
|
|||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
65ED41C7235E615E0081F399 /* PBXTargetDependency */,
|
||||
6538133D2680E28D007A082C /* PBXTargetDependency */,
|
||||
6538135E2680E47A007A082C /* PBXTargetDependency */,
|
||||
);
|
||||
|
@ -5865,11 +5857,6 @@
|
|||
target = 6581C73220CED60000F4AD34 /* Subscribe to Feed */;
|
||||
targetProxy = 65ED41C4235E61550081F399 /* PBXContainerItemProxy */;
|
||||
};
|
||||
65ED41C7235E615E0081F399 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 65ED4090235DEF770081F399 /* Subscribe to Feed MAS */;
|
||||
targetProxy = 65ED41C6235E615E0081F399 /* PBXContainerItemProxy */;
|
||||
};
|
||||
849C64731ED37A5D003D8FC0 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 849C645F1ED37A5D003D8FC0 /* NetNewsWire */;
|
||||
|
|
Loading…
Reference in New Issue