From 71ef68d4cb39dd57aa97e06258bfccec145e2503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Sat, 26 Jul 2025 13:15:41 +0200 Subject: [PATCH] Fix icons for older macOS versions --- NearbyShare/NearbyConnection.swift | 6 +----- NearbyShare/OutboundNearbyConnection.swift | 22 ++++++---------------- QuickDrop/View/WelcomeScreen.swift | 18 ++++++++++++++++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/NearbyShare/NearbyConnection.swift b/NearbyShare/NearbyConnection.swift index 72ec8df..9c6bbd2 100644 --- a/NearbyShare/NearbyConnection.swift +++ b/NearbyShare/NearbyConnection.swift @@ -415,11 +415,7 @@ class NearbyConnection { } static func hkdf(inputKeyMaterial: SymmetricKey, salt: Data, info: Data, outputByteCount: Int) -> SymmetricKey { - if #available(macOS 11.0, *) { - return HKDF.deriveKey(inputKeyMaterial: inputKeyMaterial, salt: salt, info: info, outputByteCount: outputByteCount) - } else { - return SymmetricKey(data: hkdfExpand(prk: hkdfExtract(salt: salt, ikm: inputKeyMaterial.withUnsafeBytes { Data(bytes: $0.baseAddress!, count: $0.count) }), info: info, length: outputByteCount)) - } + return HKDF.deriveKey(inputKeyMaterial: inputKeyMaterial, salt: salt, info: info, outputByteCount: outputByteCount) } func finalizeKeyExchange(peerKey: Securemessage_GenericPublicKey) throws { diff --git a/NearbyShare/OutboundNearbyConnection.swift b/NearbyShare/OutboundNearbyConnection.swift index 91962fe..9e6df0b 100644 --- a/NearbyShare/OutboundNearbyConnection.swift +++ b/NearbyShare/OutboundNearbyConnection.swift @@ -304,15 +304,9 @@ class OutboundNearbyConnection: NearbyConnection { let typeID = try? url.resourceValues(forKeys: [.typeIdentifierKey]).typeIdentifier meta.mimeType = "application/octet-stream" if let typeID = typeID { - if #available(macOS 11.0, *) { - let type = UTType(typeID) - if let type = type, let mimeType = type.preferredMIMEType { - meta.mimeType = mimeType - } - } else { - if let mimeType = UTTypeCopyPreferredTagWithClass(typeID as CFString, kUTTagClassMIMEType) { - meta.mimeType = (mimeType.takeRetainedValue() as NSString) as String - } + let type = UTType(typeID) + if let type = type, let mimeType = type.preferredMIMEType { + meta.mimeType = mimeType } } if meta.mimeType.starts(with: "image/") { @@ -400,14 +394,10 @@ class OutboundNearbyConnection: NearbyConnection { } let fileBuffer: Data - if #available(macOS 10.15.4, *) { - guard let _fileBuffer = try currentTransfer!.handle!.read(upToCount: 512 * 1024) else { - throw NearbyError.inputOutput - } - fileBuffer = _fileBuffer - } else { - fileBuffer = currentTransfer!.handle!.readData(ofLength: 512 * 1024) + guard let _fileBuffer = try currentTransfer!.handle!.read(upToCount: 512 * 1024) else { + throw NearbyError.inputOutput } + fileBuffer = _fileBuffer var transfer = Location_Nearby_Connections_PayloadTransferFrame() transfer.packetType = .data diff --git a/QuickDrop/View/WelcomeScreen.swift b/QuickDrop/View/WelcomeScreen.swift index dddab13..989c84e 100644 --- a/QuickDrop/View/WelcomeScreen.swift +++ b/QuickDrop/View/WelcomeScreen.swift @@ -40,11 +40,11 @@ struct WelcomeScreen: View { openPrivacyPolicy() } - ExternalLinkLabel(label: "AndroidApp", icon: "smartphone") { + ExternalLinkLabel(label: "AndroidApp", icon: getPhoneIcon()) { openAppAdvertisementView() } - ExternalLinkLabel(label: "TransmitUsingCable", icon: "cable.connector") { + ExternalLinkLabel(label: "TransmitUsingCable", icon: getCableIcon()) { openCableTransmissionView() } @@ -90,6 +90,20 @@ struct WelcomeScreen: View { NSWorkspace.shared.open(url) } } + + func getPhoneIcon() -> String { + if #available(macOS 14.0, *) { + return "smartphone" + } + return "iphone.rear.camera" + } + + func getCableIcon() -> String { + if #available(macOS 12.0, *) { + return "cable.connector" + } + return "externaldrive.connected.to.line.below.fill" + } }