Fix icons for older macOS versions

This commit is contained in:
Leon Böttger committed 2025-07-26 13:15:41 +02:00
1 parent b6e3943374
commit 71ef68d4cb
3 files changed
+23 -23

No files matched your search

+1 -5
View File
@@ -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<SHA256>.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<SHA256>.deriveKey(inputKeyMaterial: inputKeyMaterial, salt: salt, info: info, outputByteCount: outputByteCount)
}
func finalizeKeyExchange(peerKey: Securemessage_GenericPublicKey) throws {
+6 -16
View File
@@ -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
+16 -2
View File
@@ -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"
}
}