diff --git a/Frameworks/Account/Account.xcodeproj/project.pbxproj b/Frameworks/Account/Account.xcodeproj/project.pbxproj index 68d13d48c..9057c3188 100644 --- a/Frameworks/Account/Account.xcodeproj/project.pbxproj +++ b/Frameworks/Account/Account.xcodeproj/project.pbxproj @@ -1165,7 +1165,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "xcrun -sdk macosx swiftc -target x86_64-macosx10.11 ../../buildscripts/VerifyNoBuildSettings.swift -o $CONFIGURATION_TEMP_DIR/VerifyNoBS\n$CONFIGURATION_TEMP_DIR/VerifyNoBS ${PROJECT_NAME}.xcodeproj/project.pbxproj\n\nif [ $? -ne 0 ]\nthen\n echo \"error: Build Setting were found in the project.pbxproj file. Most likely you didn't intend to change this file and should revert it.\"\n exit 1\nfi\n"; + shellScript = "if [ \"$ENABLE_PREVIEWS\" = \"YES\" ]; then exit 0; fi\n\nxcrun -sdk macosx swiftc -target x86_64-macosx10.11 ../../buildscripts/VerifyNoBuildSettings.swift -o $CONFIGURATION_TEMP_DIR/VerifyNoBS\n$CONFIGURATION_TEMP_DIR/VerifyNoBS ${PROJECT_NAME}.xcodeproj/project.pbxproj\n\nif [ $? -ne 0 ]\nthen\n echo \"error: Build Setting were found in the project.pbxproj file. Most likely you didn't intend to change this file and should revert it.\"\n exit 1\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/Frameworks/Articles/Articles.xcodeproj/project.pbxproj b/Frameworks/Articles/Articles.xcodeproj/project.pbxproj index c8c0c3e3c..0882930f5 100644 --- a/Frameworks/Articles/Articles.xcodeproj/project.pbxproj +++ b/Frameworks/Articles/Articles.xcodeproj/project.pbxproj @@ -309,7 +309,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "xcrun -sdk macosx swiftc -target x86_64-macosx10.11 ../../buildscripts/VerifyNoBuildSettings.swift -o $CONFIGURATION_TEMP_DIR/VerifyNoBS\n$CONFIGURATION_TEMP_DIR/VerifyNoBS ${PROJECT_NAME}.xcodeproj/project.pbxproj\n\nif [ $? -ne 0 ]\nthen\n echo \"error: Build Setting were found in the project.pbxproj file. Most likely you didn't intend to change this file and should revert it.\"\n exit 1\nfi\n"; + shellScript = "if [ \"$ENABLE_PREVIEWS\" = \"YES\" ]; then exit 0; fi\n\nxcrun -sdk macosx swiftc -target x86_64-macosx10.11 ../../buildscripts/VerifyNoBuildSettings.swift -o $CONFIGURATION_TEMP_DIR/VerifyNoBS\n$CONFIGURATION_TEMP_DIR/VerifyNoBS ${PROJECT_NAME}.xcodeproj/project.pbxproj\n\nif [ $? -ne 0 ]\nthen\n echo \"error: Build Setting were found in the project.pbxproj file. Most likely you didn't intend to change this file and should revert it.\"\n exit 1\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/Frameworks/ArticlesDatabase/ArticlesDatabase.xcodeproj/project.pbxproj b/Frameworks/ArticlesDatabase/ArticlesDatabase.xcodeproj/project.pbxproj index 4a7ef6045..b5a360a7e 100644 --- a/Frameworks/ArticlesDatabase/ArticlesDatabase.xcodeproj/project.pbxproj +++ b/Frameworks/ArticlesDatabase/ArticlesDatabase.xcodeproj/project.pbxproj @@ -517,7 +517,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "xcrun -sdk macosx swiftc -target x86_64-macosx10.11 ../../buildscripts/VerifyNoBuildSettings.swift -o $CONFIGURATION_TEMP_DIR/VerifyNoBS\n$CONFIGURATION_TEMP_DIR/VerifyNoBS ${PROJECT_NAME}.xcodeproj/project.pbxproj\n\nif [ $? -ne 0 ]\nthen\n echo \"error: Build Setting were found in the project.pbxproj file. Most likely you didn't intend to change this file and should revert it.\"\n exit 1\nfi\n"; + shellScript = "if [ \"$ENABLE_PREVIEWS\" = \"YES\" ]; then exit 0; fi\n\nxcrun -sdk macosx swiftc -target x86_64-macosx10.11 ../../buildscripts/VerifyNoBuildSettings.swift -o $CONFIGURATION_TEMP_DIR/VerifyNoBS\n$CONFIGURATION_TEMP_DIR/VerifyNoBS ${PROJECT_NAME}.xcodeproj/project.pbxproj\n\nif [ $? -ne 0 ]\nthen\n echo \"error: Build Setting were found in the project.pbxproj file. Most likely you didn't intend to change this file and should revert it.\"\n exit 1\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/Frameworks/Secrets/Secrets.xcodeproj/project.pbxproj b/Frameworks/Secrets/Secrets.xcodeproj/project.pbxproj index 5cc15d12b..42386e90d 100644 --- a/Frameworks/Secrets/Secrets.xcodeproj/project.pbxproj +++ b/Frameworks/Secrets/Secrets.xcodeproj/project.pbxproj @@ -183,7 +183,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "xcrun -sdk macosx swiftc -target x86_64-macosx10.11 ../../buildscripts/VerifyNoBuildSettings.swift -o $CONFIGURATION_TEMP_DIR/VerifyNoBS\n$CONFIGURATION_TEMP_DIR/VerifyNoBS ${PROJECT_NAME}.xcodeproj/project.pbxproj\n\nif [ $? -ne 0 ]\nthen\n echo \"error: Build Setting were found in the project.pbxproj file. Most likely you didn't intend to change this file and should revert it.\"\n exit 1\nfi\n"; + shellScript = "if [ \"$ENABLE_PREVIEWS\" = \"YES\" ]; then exit 0; fi\n\nxcrun -sdk macosx swiftc -target x86_64-macosx10.11 ../../buildscripts/VerifyNoBuildSettings.swift -o $CONFIGURATION_TEMP_DIR/VerifyNoBS\n$CONFIGURATION_TEMP_DIR/VerifyNoBS ${PROJECT_NAME}.xcodeproj/project.pbxproj\n\nif [ $? -ne 0 ]\nthen\n echo \"error: Build Setting were found in the project.pbxproj file. Most likely you didn't intend to change this file and should revert it.\"\n exit 1\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/Frameworks/SyncDatabase/SyncDatabase.xcodeproj/project.pbxproj b/Frameworks/SyncDatabase/SyncDatabase.xcodeproj/project.pbxproj index 69ca2e492..113fc6111 100644 --- a/Frameworks/SyncDatabase/SyncDatabase.xcodeproj/project.pbxproj +++ b/Frameworks/SyncDatabase/SyncDatabase.xcodeproj/project.pbxproj @@ -183,7 +183,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "xcrun -sdk macosx swiftc -target x86_64-macosx10.11 ../../buildscripts/VerifyNoBuildSettings.swift -o $CONFIGURATION_TEMP_DIR/VerifyNoBS\n$CONFIGURATION_TEMP_DIR/VerifyNoBS ${PROJECT_NAME}.xcodeproj/project.pbxproj\n\nif [ $? -ne 0 ]\nthen\n echo \"error: Build Setting were found in the project.pbxproj file. Most likely you didn't intend to change this file and should revert it.\"\n exit 1\nfi\n\n"; + shellScript = "if [ \"$ENABLE_PREVIEWS\" = \"YES\" ]; then exit 0; fi\n\nxcrun -sdk macosx swiftc -target x86_64-macosx10.11 ../../buildscripts/VerifyNoBuildSettings.swift -o $CONFIGURATION_TEMP_DIR/VerifyNoBS\n$CONFIGURATION_TEMP_DIR/VerifyNoBS ${PROJECT_NAME}.xcodeproj/project.pbxproj\n\nif [ $? -ne 0 ]\nthen\n echo \"error: Build Setting were found in the project.pbxproj file. Most likely you didn't intend to change this file and should revert it.\"\n exit 1\nfi\n\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/Mac/AppAssets.swift b/Mac/AppAssets.swift index 5e4699fa1..b9f702e03 100644 --- a/Mac/AppAssets.swift +++ b/Mac/AppAssets.swift @@ -125,6 +125,10 @@ struct AppAssets { return IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!) }() + static var smartFeedImage: RSImage = { + return RSImage(named: NSImage.smartBadgeTemplateName)! + }() + static var starredFeedImage: IconImage = { return IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!) }() diff --git a/Mac/AppDefaults.swift b/Mac/AppDefaults.swift index 447d5b4cf..278a53525 100644 --- a/Mac/AppDefaults.swift +++ b/Mac/AppDefaults.swift @@ -14,7 +14,10 @@ enum FontSize: Int { case veryLarge = 3 } -struct AppDefaults { +final class AppDefaults { + + static var shared = AppDefaults() + private init() {} struct Key { static let firstRunDate = "firstRunDate" @@ -50,14 +53,14 @@ struct AppDefaults { private static let smallestFontSizeRawValue = FontSize.small.rawValue private static let largestFontSizeRawValue = FontSize.veryLarge.rawValue - static let isDeveloperBuild: Bool = { + let isDeveloperBuild: Bool = { if let dev = Bundle.main.object(forInfoDictionaryKey: "DeveloperEntitlements") as? String, dev == "-dev" { return true } return false }() - static let isFirstRun: Bool = { + var isFirstRun: Bool = { if let _ = UserDefaults.standard.object(forKey: Key.firstRunDate) as? Date { return false } @@ -65,7 +68,7 @@ struct AppDefaults { return true }() - static var windowState: [AnyHashable : Any]? { + var windowState: [AnyHashable : Any]? { get { return UserDefaults.standard.object(forKey: Key.windowState) as? [AnyHashable : Any] } @@ -74,7 +77,7 @@ struct AppDefaults { } } - static var activeExtensionPointIDs: [[AnyHashable : AnyHashable]]? { + var activeExtensionPointIDs: [[AnyHashable : AnyHashable]]? { get { return UserDefaults.standard.object(forKey: Key.activeExtensionPointIDs) as? [[AnyHashable : AnyHashable]] } @@ -83,160 +86,160 @@ struct AppDefaults { } } - static var lastImageCacheFlushDate: Date? { + var lastImageCacheFlushDate: Date? { get { - return date(for: Key.lastImageCacheFlushDate) + return AppDefaults.date(for: Key.lastImageCacheFlushDate) } set { - setDate(for: Key.lastImageCacheFlushDate, newValue) + AppDefaults.setDate(for: Key.lastImageCacheFlushDate, newValue) } } - static var openInBrowserInBackground: Bool { + var openInBrowserInBackground: Bool { get { - return bool(for: Key.openInBrowserInBackground) + return AppDefaults.bool(for: Key.openInBrowserInBackground) } set { - setBool(for: Key.openInBrowserInBackground, newValue) + AppDefaults.setBool(for: Key.openInBrowserInBackground, newValue) } } - static var sidebarFontSize: FontSize { + var sidebarFontSize: FontSize { get { return fontSize(for: Key.sidebarFontSize) } set { - setFontSize(for: Key.sidebarFontSize, newValue) + AppDefaults.setFontSize(for: Key.sidebarFontSize, newValue) } } - static var timelineFontSize: FontSize { + var timelineFontSize: FontSize { get { return fontSize(for: Key.timelineFontSize) } set { - setFontSize(for: Key.timelineFontSize, newValue) + AppDefaults.setFontSize(for: Key.timelineFontSize, newValue) } } - static var detailFontSize: FontSize { + var detailFontSize: FontSize { get { return fontSize(for: Key.detailFontSize) } set { - setFontSize(for: Key.detailFontSize, newValue) + AppDefaults.setFontSize(for: Key.detailFontSize, newValue) } } - static var addWebFeedAccountID: String? { + var addWebFeedAccountID: String? { get { - return string(for: Key.addWebFeedAccountID) + return AppDefaults.string(for: Key.addWebFeedAccountID) } set { - setString(for: Key.addWebFeedAccountID, newValue) + AppDefaults.setString(for: Key.addWebFeedAccountID, newValue) } } - static var addWebFeedFolderName: String? { + var addWebFeedFolderName: String? { get { - return string(for: Key.addWebFeedFolderName) + return AppDefaults.string(for: Key.addWebFeedFolderName) } set { - setString(for: Key.addWebFeedFolderName, newValue) + AppDefaults.setString(for: Key.addWebFeedFolderName, newValue) } } - static var addFolderAccountID: String? { + var addFolderAccountID: String? { get { - return string(for: Key.addFolderAccountID) + return AppDefaults.string(for: Key.addFolderAccountID) } set { - setString(for: Key.addFolderAccountID, newValue) + AppDefaults.setString(for: Key.addFolderAccountID, newValue) } } - static var importOPMLAccountID: String? { + var importOPMLAccountID: String? { get { - return string(for: Key.importOPMLAccountID) + return AppDefaults.string(for: Key.importOPMLAccountID) } set { - setString(for: Key.importOPMLAccountID, newValue) + AppDefaults.setString(for: Key.importOPMLAccountID, newValue) } } - static var exportOPMLAccountID: String? { + var exportOPMLAccountID: String? { get { - return string(for: Key.exportOPMLAccountID) + return AppDefaults.string(for: Key.exportOPMLAccountID) } set { - setString(for: Key.exportOPMLAccountID, newValue) + AppDefaults.setString(for: Key.exportOPMLAccountID, newValue) } } - static var defaultBrowserID: String? { + var defaultBrowserID: String? { get { - return string(for: Key.defaultBrowserID) + return AppDefaults.string(for: Key.defaultBrowserID) } set { - setString(for: Key.defaultBrowserID, newValue) + AppDefaults.setString(for: Key.defaultBrowserID, newValue) } } - static var showTitleOnMainWindow: Bool { - return bool(for: Key.showTitleOnMainWindow) + var showTitleOnMainWindow: Bool { + return AppDefaults.bool(for: Key.showTitleOnMainWindow) } - static var showDebugMenu: Bool { - return bool(for: Key.showDebugMenu) + var showDebugMenu: Bool { + return AppDefaults.bool(for: Key.showDebugMenu) } - static var hideDockUnreadCount: Bool { - return bool(for: Key.hideDockUnreadCount) + var hideDockUnreadCount: Bool { + return AppDefaults.bool(for: Key.hideDockUnreadCount) } #if !MAC_APP_STORE - static var webInspectorEnabled: Bool { + var webInspectorEnabled: Bool { get { - return bool(for: Key.webInspectorEnabled) + return AppDefaults.bool(for: Key.webInspectorEnabled) } set { - setBool(for: Key.webInspectorEnabled, newValue) + AppDefaults.setBool(for: Key.webInspectorEnabled, newValue) } } - static var webInspectorStartsAttached: Bool { + var webInspectorStartsAttached: Bool { get { - return bool(for: Key.webInspectorStartsAttached) + return AppDefaults.bool(for: Key.webInspectorStartsAttached) } set { - setBool(for: Key.webInspectorStartsAttached, newValue) + AppDefaults.setBool(for: Key.webInspectorStartsAttached, newValue) } } #endif - static var timelineSortDirection: ComparisonResult { + var timelineSortDirection: ComparisonResult { get { - return sortDirection(for: Key.timelineSortDirection) + return AppDefaults.sortDirection(for: Key.timelineSortDirection) } set { - setSortDirection(for: Key.timelineSortDirection, newValue) + AppDefaults.setSortDirection(for: Key.timelineSortDirection, newValue) } } - static var timelineGroupByFeed: Bool { + var timelineGroupByFeed: Bool { get { - return bool(for: Key.timelineGroupByFeed) + return AppDefaults.bool(for: Key.timelineGroupByFeed) } set { - setBool(for: Key.timelineGroupByFeed, newValue) + AppDefaults.setBool(for: Key.timelineGroupByFeed, newValue) } } - static var timelineShowsSeparators: Bool { - return bool(for: Key.timelineShowsSeparators) + var timelineShowsSeparators: Bool { + return AppDefaults.bool(for: Key.timelineShowsSeparators) } - static var refreshInterval: RefreshInterval { + var refreshInterval: RefreshInterval { get { let rawValue = UserDefaults.standard.integer(forKey: Key.refreshInterval) return RefreshInterval(rawValue: rawValue) ?? RefreshInterval.everyHour @@ -246,7 +249,7 @@ struct AppDefaults { } } - static func registerDefaults() { + func registerDefaults() { #if DEBUG let showDebugMenu = true #else @@ -278,7 +281,7 @@ struct AppDefaults { // TODO: revisit the above when coming back to state restoration issues. } - static func actualFontSize(for fontSize: FontSize) -> CGFloat { + func actualFontSize(for fontSize: FontSize) -> CGFloat { switch fontSize { case .small: return NSFont.systemFontSize @@ -296,14 +299,14 @@ private extension AppDefaults { static var firstRunDate: Date? { get { - return date(for: Key.firstRunDate) + return AppDefaults.date(for: Key.firstRunDate) } set { - setDate(for: Key.firstRunDate, newValue) + AppDefaults.setDate(for: Key.firstRunDate, newValue) } } - static func fontSize(for key: String) -> FontSize { + func fontSize(for key: String) -> FontSize { // Punted till after 1.0. return .medium diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index e8fbaa4ce..2a4dc590a 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -191,8 +191,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, } #endif - AppDefaults.registerDefaults() - let isFirstRun = AppDefaults.isFirstRun + AppDefaults.shared.registerDefaults() + let isFirstRun = AppDefaults.shared.isFirstRun if isFirstRun { logDebugMessage("Is first run.") } @@ -237,7 +237,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, UNUserNotificationCenter.current().delegate = self userNotificationManager = UserNotificationManager() - if AppDefaults.showDebugMenu { + if AppDefaults.shared.showDebugMenu { refreshTimer!.update() syncTimer!.update() @@ -417,7 +417,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, } #if !MAC_APP_STORE if item.action == #selector(toggleWebInspectorEnabled(_:)) { - (item as! NSMenuItem).state = AppDefaults.webInspectorEnabled ? .on : .off + (item as! NSMenuItem).state = AppDefaults.shared.webInspectorEnabled ? .on : .off } #endif return true @@ -447,7 +447,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, // MARK: - Dock Badge @objc func updateDockBadge() { - let label = unreadCount > 0 && !AppDefaults.hideDockUnreadCount ? "\(unreadCount)" : "" + let label = unreadCount > 0 && !AppDefaults.shared.hideDockUnreadCount ? "\(unreadCount)" : "" NSApplication.shared.dockTile.badgeLabel = label } @@ -624,16 +624,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, @IBAction func sortByOldestArticleOnTop(_ sender: Any?) { - AppDefaults.timelineSortDirection = .orderedAscending + AppDefaults.shared.timelineSortDirection = .orderedAscending } @IBAction func sortByNewestArticleOnTop(_ sender: Any?) { - AppDefaults.timelineSortDirection = .orderedDescending + AppDefaults.shared.timelineSortDirection = .orderedDescending } @IBAction func groupByFeedToggled(_ sender: NSMenuItem) { - AppDefaults.timelineGroupByFeed.toggle() + AppDefaults.shared.timelineGroupByFeed.toggle() } @IBAction func checkForUpdates(_ sender: Any?) { @@ -680,13 +680,13 @@ extension AppDelegate { @IBAction func toggleWebInspectorEnabled(_ sender: Any?) { #if !MAC_APP_STORE - let newValue = !AppDefaults.webInspectorEnabled - AppDefaults.webInspectorEnabled = newValue + let newValue = !AppDefaults.shared.webInspectorEnabled + AppDefaults.shared.webInspectorEnabled = newValue // An attached inspector can display incorrectly on certain setups (like mine); default to displaying in a separate window, // and reset the default to a separate window when the preference is toggled off and on again in case the inspector is // accidentally reattached. - AppDefaults.webInspectorStartsAttached = false + AppDefaults.shared.webInspectorStartsAttached = false NotificationCenter.default.post(name: .WebInspectorEnabledDidChange, object: newValue) #endif } @@ -717,13 +717,13 @@ private extension AppDelegate { func updateSortMenuItems() { - let sortByNewestOnTop = AppDefaults.timelineSortDirection == .orderedDescending + let sortByNewestOnTop = AppDefaults.shared.timelineSortDirection == .orderedDescending sortByNewestArticleOnTopMenuItem.state = sortByNewestOnTop ? .on : .off sortByOldestArticleOnTopMenuItem.state = sortByNewestOnTop ? .off : .on } func updateGroupByFeedMenuItem() { - let groupByFeedEnabled = AppDefaults.timelineGroupByFeed + let groupByFeedEnabled = AppDefaults.shared.timelineGroupByFeed groupArticlesByFeedMenuItem.state = groupByFeedEnabled ? .on : .off } } diff --git a/Mac/Base.lproj/Preferences.storyboard b/Mac/Base.lproj/Preferences.storyboard index 0c90be9b1..a48d6bdf8 100644 --- a/Mac/Base.lproj/Preferences.storyboard +++ b/Mac/Base.lproj/Preferences.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -31,14 +32,14 @@ - + - + - + @@ -46,13 +47,13 @@ - + - + @@ -81,7 +82,7 @@ - + @@ -89,10 +90,10 @@ - + - + @@ -104,7 +105,7 @@ - + @@ -132,7 +133,7 @@ - + - + - + - + @@ -176,7 +177,7 @@ - + @@ -242,14 +243,14 @@ - + - + - + @@ -257,7 +258,7 @@