Merge branch 'theme_reloading_fix' into super-cut

This commit is contained in:
Maurice Parker
2023-04-01 19:56:24 -05:00
4 changed files with 34 additions and 15 deletions

View File

@@ -62,7 +62,7 @@
<key>NSAppleScriptEnabled</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2002-2022 Brent Simmons. All rights reserved.</string>
<string>Copyright © 2002-2023 Brent Simmons. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>

View File

@@ -20,9 +20,7 @@ final class ArticleThemesManager: NSObject, NSFilePresenter, Logging {
public let folderPath: String
lazy var presentedItemOperationQueue = OperationQueue.main
var presentedItemURL: URL? {
return URL(fileURLWithPath: folderPath)
}
var presentedItemURL: URL?
var currentThemeName: String {
get {
@@ -33,6 +31,7 @@ final class ArticleThemesManager: NSObject, NSFilePresenter, Logging {
do {
currentTheme = try articleThemeWithThemeName(newValue)
AppDefaults.shared.currentThemeName = newValue
updateFilePresenter()
} catch {
logger.error("Unable to set new theme: \(error.localizedDescription, privacy: .public)")
}
@@ -71,18 +70,22 @@ final class ArticleThemesManager: NSObject, NSFilePresenter, Logging {
assertionFailure("Could not create folder for Themes.")
abort()
}
NSFileCoordinator.addFilePresenter(self)
#if os(macOS)
NotificationCenter.default.addObserver(self, selector: #selector(applicationDidBecomeActive(_:)), name: NSApplication.didBecomeActiveNotification, object: nil)
#else
NotificationCenter.default.addObserver(self, selector: #selector(applicationDidBecomeActive(_:)), name: UIApplication.didBecomeActiveNotification, object: nil)
#endif
updateFilePresenter()
}
func presentedSubitemDidChange(at url: URL) {
if url.lastPathComponent.localizedCaseInsensitiveContains("nnwtheme") {
themeNames = buildThemeNames()
do {
currentTheme = try articleThemeWithThemeName(currentThemeName)
} catch {
appDelegate.presentThemeImportError(error)
}
themeNames = buildThemeNames()
do {
currentTheme = try articleThemeWithThemeName(currentThemeName)
} catch {
appDelegate.presentThemeImportError(error)
}
}
@@ -103,6 +106,8 @@ final class ArticleThemesManager: NSObject, NSFilePresenter, Logging {
}
try FileManager.default.copyItem(atPath: filename, toPath: toFilename)
themeNames = buildThemeNames()
}
func articleThemeWithThemeName(_ themeName: String) throws -> ArticleTheme {
@@ -128,6 +133,7 @@ final class ArticleThemesManager: NSObject, NSFilePresenter, Logging {
func deleteTheme(themeName: String) {
if let filename = pathForThemeName(themeName, folder: folderPath) {
try? FileManager.default.removeItem(atPath: filename)
themeNames = buildThemeNames()
}
}
@@ -136,6 +142,19 @@ final class ArticleThemesManager: NSObject, NSFilePresenter, Logging {
// MARK : Private
private extension ArticleThemesManager {
@objc func applicationDidBecomeActive(_ note: Notification) {
themeNames = buildThemeNames()
}
func updateFilePresenter() {
guard let currentThemePath = currentTheme.path else {
return
}
NSFileCoordinator.removeFilePresenter(self)
presentedItemURL = URL(fileURLWithPath: currentThemePath)
NSFileCoordinator.addFilePresenter(self)
}
func buildThemeNames() -> [String] {
let appThemeFilenames = Bundle.main.paths(forResourcesOfType: ArticleTheme.nnwThemeSuffix, inDirectory: nil)

View File

@@ -695,7 +695,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner, Ma
private func showTwitterDeprecationAlert() {
let alert = UIAlertController(title: NSLocalizedString("Twitter Integration Removed", comment: "Twitter Integration Removed"),
message: NSLocalizedString("On February 1, 2023, Twitter announced the end of free access to the Twitter API, effective February 9.\n\nSince Twitter does not provide RSS feeds, weve had to use the Twitter API. Without free access to that API, we cant read feeds from Twitter.\n\nWeve left your Twitter feeds intact. If you have any starred items from those feeds, they will remain as long as you dont delete those feeds.\n\nYou can still read whatever you have already downloaded. However, those feeds will no longer update.", comment: "Twitter deprecation message"),
message: NSLocalizedString("Twitter has ended free access to the parts of the Twitter API that we need.\n\nSince Twitter does not provide RSS feeds, weve had to use the Twitter API. Without free access to that API, we cant read feeds from Twitter.\n\nWeve left your Twitter feeds intact. If you have any starred items from those feeds, they will remain as long as you dont delete those feeds.\n\nYou can still read whatever you have already downloaded. However, those feeds will no longer update.", comment: "Twitter deprecation message"),
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .cancel))

View File

@@ -1,7 +1,7 @@
// High Level Settings common to both the iOS application and any extensions we bundle with it
MARKETING_VERSION = 6.1.1
CURRENT_PROJECT_VERSION = 6114
CURRENT_PROJECT_VERSION = 6115
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon