Fix several iOS 17 deprecation warnings.

This commit is contained in:
Brent Simmons 2024-11-03 22:40:38 -08:00
parent 8644380d07
commit 4f0cacdd3f
11 changed files with 35 additions and 28 deletions

View File

@ -106,7 +106,3 @@ class ImportOPMLWindowController: NSWindowController {
}
extension UTType {
static let opml = UTType("public.opml")!
}

View File

@ -407,6 +407,8 @@
841387852CD897EF00E8490F /* RSCoreObjC in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 841387832CD897EF00E8490F /* RSCoreObjC */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
841387872CD89E5200E8490F /* RSCore in Frameworks */ = {isa = PBXBuildFile; productRef = 841387862CD89E5200E8490F /* RSCore */; };
841387882CD89E5200E8490F /* RSCore in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 841387862CD89E5200E8490F /* RSCore */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
8413878A2CD8A38A00E8490F /* UniformTypeIdentifiers+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841387892CD8A38A00E8490F /* UniformTypeIdentifiers+Extras.swift */; };
8413878B2CD8A38A00E8490F /* UniformTypeIdentifiers+Extras.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841387892CD8A38A00E8490F /* UniformTypeIdentifiers+Extras.swift */; };
84162A152038C12C00035290 /* MarkCommandValidationStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */; };
841ABA4E20145E7300980E11 /* NothingInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */; };
841ABA5E20145E9200980E11 /* FolderInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA5D20145E9200980E11 /* FolderInspectorViewController.swift */; };
@ -1051,6 +1053,7 @@
840D61952029031D009BC708 /* NetNewsWire_iOSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetNewsWire_iOSTests.swift; sourceTree = "<group>"; };
840D61972029031D009BC708 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8413876B2CD896E000E8490F /* RSCore */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = RSCore; sourceTree = "<group>"; };
841387892CD8A38A00E8490F /* UniformTypeIdentifiers+Extras.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UniformTypeIdentifiers+Extras.swift"; sourceTree = "<group>"; };
84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkCommandValidationStatus.swift; sourceTree = "<group>"; };
841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NothingInspectorViewController.swift; sourceTree = "<group>"; };
841ABA5D20145E9200980E11 /* FolderInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderInspectorViewController.swift; sourceTree = "<group>"; };
@ -2141,6 +2144,7 @@
511D43CE231FA51100FB1562 /* Resources */,
176813A22564B9D100D98635 /* Widget */,
173A64162547BE0900267F6E /* AccountType+Helpers.swift */,
841387892CD8A38A00E8490F /* UniformTypeIdentifiers+Extras.swift */,
);
path = Shared;
sourceTree = "<group>";
@ -3196,6 +3200,7 @@
51B5C87B23F2317700032075 /* ExtensionFeedAddRequest.swift in Sources */,
51627A93238A3836007B3B4B /* CroppingPreviewParameters.swift in Sources */,
512AF9DD236F05230066F8BE /* InteractiveLabel.swift in Sources */,
8413878A2CD8A38A00E8490F /* UniformTypeIdentifiers+Extras.swift in Sources */,
51E3EB3D229AB08300645299 /* ErrorHandler.swift in Sources */,
5183CCE5226F4DFA0010922C /* RefreshInterval.swift in Sources */,
51C4529D22650A1000C03939 /* FaviconURLFinder.swift in Sources */,
@ -3454,6 +3459,7 @@
849A977A1ED9EC04007D329B /* TimelineTableCellView.swift in Sources */,
849A97761ED9EC04007D329B /* TimelineCellAppearance.swift in Sources */,
849A977F1ED9EC42007D329B /* ArticleRenderer.swift in Sources */,
8413878B2CD8A38A00E8490F /* UniformTypeIdentifiers+Extras.swift in Sources */,
84C9FC7822629E1200D921D6 /* GeneralPrefencesViewController.swift in Sources */,
179DB3CE822BFCC2D774D9F4 /* AccountsNewsBlurWindowController.swift in Sources */,
);

View File

@ -219,7 +219,7 @@ private extension ActivityManager {
#if os(iOS)
func updateReadArticleSearchAttributes(with article: Article) {
let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeCompositeContent as String)
let attributeSet = CSSearchableItemAttributeSet(itemContentType: UTType.compositeContent.identifier)
attributeSet.title = ArticleStringFormatter.truncatedTitle(article)
attributeSet.contentDescription = article.summary
attributeSet.keywords = makeKeywords(article)

View File

@ -245,7 +245,7 @@ extension NSAttributedString {
#if canImport(AppKit)
let features: [FontDescriptor.FeatureKey: Any] = [.typeIdentifier: kVerticalPositionType, .selectorIdentifier: forSuperscript ? kSuperiorsSelector : kInferiorsSelector]
#else
let features: [FontDescriptor.FeatureKey: Any] = [.featureIdentifier: kVerticalPositionType, .typeIdentifier: forSuperscript ? kSuperiorsSelector : kInferiorsSelector]
let features: [FontDescriptor.FeatureKey: Any] = [.type: kVerticalPositionType, .selector: forSuperscript ? kSuperiorsSelector : kInferiorsSelector]
#endif
return features
}

View File

@ -0,0 +1,14 @@
//
// UniformTypeIdentifiers+Extras.swift
// NetNewsWire
//
// Created by Brent Simmons on 11/3/24.
// Copyright © 2024 Ranchero Software. All rights reserved.
//
import UniformTypeIdentifiers
extension UTType {
static let opml = UTType("public.opml")!
}

View File

@ -62,8 +62,6 @@ private extension UserNotificationManager {
}
content.body = ArticleStringFormatter.truncatedSummary(article)
content.threadIdentifier = feed.feedID
content.summaryArgument = "\(feed.nameForDisplay)"
content.summaryArgumentCount = 1
content.sound = UNNotificationSound.default
content.userInfo = [UserInfoKey.articlePath: article.pathUserInfo]
content.categoryIdentifier = "NEW_ARTICLE_NOTIFICATION_CATEGORY"

View File

@ -51,7 +51,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
didSet {
if unreadCount != oldValue {
postUnreadCountDidChangeNotification()
UIApplication.shared.applicationIconBadgeNumber = unreadCount
UNUserNotificationCenter.current().setBadgeCount(unreadCount)
}
}
}
@ -196,7 +196,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
}
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .badge, .sound])
completionHandler([.list, .banner, .badge, .sound])
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {

View File

@ -17,10 +17,10 @@ class PreloadedWebView: WKWebView {
init(articleIconSchemeHandler: ArticleIconSchemeHandler) {
let preferences = WKPreferences()
preferences.javaScriptCanOpenWindowsAutomatically = false
preferences.javaScriptEnabled = true
let configuration = WKWebViewConfiguration()
configuration.preferences = preferences
configuration.defaultWebpagePreferences.allowsContentJavaScript = true
configuration.setValue(true, forKey: "allowUniversalAccessFromFileURLs")
configuration.allowsInlineMediaPlayback = true
configuration.mediaTypesRequiringUserActionForPlayback = .audio

View File

@ -9,6 +9,7 @@
import UIKit
import MobileCoreServices
import Account
import UniformTypeIdentifiers
extension MasterFeedViewController: UITableViewDragDelegate {
@ -20,7 +21,7 @@ extension MasterFeedViewController: UITableViewDragDelegate {
let data = feed.url.data(using: .utf8)
let itemProvider = NSItemProvider()
itemProvider.registerDataRepresentation(forTypeIdentifier: kUTTypeURL as String, visibility: .ownProcess) { completion in
itemProvider.registerDataRepresentation(forTypeIdentifier: UTType.url.identifier, visibility: .ownProcess) { completion in
completion(data, nil)
return nil
}

View File

@ -332,7 +332,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
func start(for size: CGSize) -> UIViewController {
rootSplitViewController = RootSplitViewController()
rootSplitViewController.coordinator = self
rootSplitViewController.preferredDisplayMode = .allVisible
rootSplitViewController.preferredDisplayMode = .oneBesideSecondary
rootSplitViewController.viewControllers = [InteractiveNavigationController.template()]
rootSplitViewController.delegate = self
@ -1304,7 +1304,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner {
}
func toggleSidebar() {
rootSplitViewController.preferredDisplayMode = rootSplitViewController.displayMode == .allVisible ? .primaryHidden : .allVisible
rootSplitViewController.preferredDisplayMode = rootSplitViewController.displayMode == .oneBesideSecondary ? .secondaryOnly : .oneBesideSecondary
}
func selectArticleInCurrentFeed(_ articleID: String, isShowingExtractedArticle: Bool? = nil, articleWindowScrollY: Int? = nil) {
@ -2161,7 +2161,7 @@ private extension SceneCoordinator {
rootSplitViewController.preferredPrimaryColumnWidthFraction = 0.30
subSplitViewController = UISplitViewController()
subSplitViewController!.preferredDisplayMode = .allVisible
subSplitViewController!.preferredDisplayMode = .oneBesideSecondary
subSplitViewController!.viewControllers = [InteractiveNavigationController.template()]
subSplitViewController!.preferredPrimaryColumnWidthFraction = 0.4285

View File

@ -11,6 +11,7 @@ import Account
import CoreServices
import SafariServices
import SwiftUI
import UniformTypeIdentifiers
class SettingsViewController: UITableViewController {
@ -418,19 +419,10 @@ private extension SettingsViewController {
func importOPMLDocumentPicker() {
let utiArray = UTTypeCreateAllIdentifiersForTag(kUTTagClassFilenameExtension, "opml" as NSString, nil)?.takeRetainedValue() as? [String] ?? [String]()
var opmlUTIs = utiArray
.compactMap({ UTTypeCopyDeclaration($0 as NSString)?.takeUnretainedValue() as? [String: Any] })
.reduce([String]()) { (result, dict) in
return result + dict.values.compactMap({ $0 as? String })
}
opmlUTIs.append("public.xml")
let docPicker = UIDocumentPickerViewController(documentTypes: opmlUTIs, in: .import)
docPicker.delegate = self
docPicker.modalPresentationStyle = .formSheet
self.present(docPicker, animated: true)
let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.opml, UTType.xml], asCopy: true)
documentPicker.delegate = self
documentPicker.modalPresentationStyle = .formSheet
self.present(documentPicker, animated: true)
}
func exportOPML(sourceView: UIView, sourceRect: CGRect) {