Add device name lookup for unnamed devices

This commit is contained in:
Leon Böttger committed 2026-04-27 20:29:35 +02:00
1 parent 84d2150893
commit e6d1c7b1a3
9 files changed
+397 -24

No files matched your search

+9 -2
View File
@@ -95,6 +95,9 @@ class ShareViewController: NSViewController, OutboundAppDelegate {
progressDeviceIconWrap!.wantsLayer = true
progressDeviceIconWrap!.layer!.masksToBounds = false
progressDeviceSecondaryIcon?.image = NSImage(named: "MenuBarIcon")
progressDeviceSecondaryIcon?.image?.isTemplate = true
progressDeviceSecondaryIcon?.contentTintColor = .white
}
@@ -250,6 +253,7 @@ class ShareViewController: NSViewController, OutboundAppDelegate {
progressView?.animator().isHidden = false
progressDeviceName?.stringValue = getDeviceName(device: device)
progressDeviceIcon?.image = imageForDeviceType(type: device.type)
progressDeviceSecondaryIcon?.isHidden = !device.isQuickDropPeer
progressProgressBar?.startAnimation(nil)
progressState?.stringValue = "Preparing".localized()
chosenDevice = device
@@ -383,8 +387,11 @@ extension ShareViewController: NSCollectionViewDataSource {
let device = foundDevices[indexPath[1]]
collectionViewItem.textField?.stringValue = getDeviceName(device: device)
collectionViewItem.imageView?.image = imageForDeviceType(type: device.type)
collectionViewItem.configure(
deviceName: getDeviceName(device: device),
deviceImage: imageForDeviceType(type: device.type),
showsQuickDropPeerMarker: device.isQuickDropPeer && device.type == .phone
)
collectionViewItem.clickHandler = {
self.selectDevice(device: device)
}
@@ -177,17 +177,17 @@ Gw
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="rb3-78-PXe"/>
</imageView>
<imageView hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="BEO-kU-a2Q">
<rect key="frame" x="24" y="-8" width="32" height="32"/>
<rect key="frame" x="16.800000000000001" y="16.800000000000001" width="14.4" height="14.4"/>
<constraints>
<constraint firstAttribute="height" constant="32" id="05I-Ef-84Z"/>
<constraint firstAttribute="width" constant="32" id="V0g-Fz-HWH"/>
<constraint firstAttribute="height" constant="14.4" id="05I-Ef-84Z"/>
<constraint firstAttribute="width" constant="14.4" id="V0g-Fz-HWH"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSCaution" id="k1c-Xl-fTQ"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="k1c-Xl-fTQ"/>
</imageView>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="BEO-kU-a2Q" secondAttribute="trailing" constant="-8" id="59U-Zi-ESa"/>
<constraint firstAttribute="bottom" secondItem="BEO-kU-a2Q" secondAttribute="bottom" constant="-8" id="8ty-pq-miR"/>
<constraint firstItem="BEO-kU-a2Q" firstAttribute="centerX" secondItem="84U-lB-SRB" secondAttribute="centerX" id="59U-Zi-ESa"/>
<constraint firstItem="BEO-kU-a2Q" firstAttribute="centerY" secondItem="84U-lB-SRB" secondAttribute="centerY" id="8ty-pq-miR"/>
<constraint firstItem="84U-lB-SRB" firstAttribute="top" secondItem="jBg-Ih-Gac" secondAttribute="top" id="MB9-UI-2mb"/>
<constraint firstItem="84U-lB-SRB" firstAttribute="leading" secondItem="jBg-Ih-Gac" secondAttribute="leading" id="b23-hJ-aWT"/>
<constraint firstAttribute="trailing" secondItem="84U-lB-SRB" secondAttribute="trailing" id="eKl-3V-K49"/>
+11
View File
@@ -9,6 +9,7 @@ import Cocoa
class DeviceListCell: NSCollectionViewItem {
public var clickHandler: (() -> Void)?
@IBOutlet private var peerMarkerView: NSImageView?
override func viewDidLoad() {
super.viewDidLoad()
@@ -17,10 +18,20 @@ class DeviceListCell: NSCollectionViewItem {
btn.setButtonType(.momentaryPushIn)
btn.action = #selector(onClick)
btn.target = self
peerMarkerView?.image = NSImage(named: "MenuBarIcon")
peerMarkerView?.image?.isTemplate = true
peerMarkerView?.contentTintColor = .white
}
@IBAction func onClick(_: Any?) {
guard let handler = clickHandler else { return }
handler()
}
func configure(deviceName: String, deviceImage: NSImage, showsQuickDropPeerMarker: Bool) {
textField?.stringValue = deviceName
imageView?.image = deviceImage
peerMarkerView?.isHidden = !showsQuickDropPeerMarker
}
}
+11
View File
@@ -36,10 +36,20 @@
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="QGU-rR-rJQ"/>
</imageView>
<imageView hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="89K-DQ-f8g">
<rect key="frame" x="95.799999999999997" y="58.799999999999997" width="14.4" height="14.4"/>
<constraints>
<constraint firstAttribute="width" constant="14.4" id="Lfh-Ha-Njl"/>
<constraint firstAttribute="height" constant="14.4" id="Wm1-YW-85X"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="0fp-y5-fj9"/>
</imageView>
</subviews>
<constraints>
<constraint firstItem="89K-DQ-f8g" firstAttribute="centerX" secondItem="O1J-am-CoK" secondAttribute="centerX" id="Bja-VK-UQf"/>
<constraint firstItem="O1J-am-CoK" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="R76-2L-pXb"/>
<constraint firstAttribute="bottom" secondItem="QPM-sE-maP" secondAttribute="bottom" id="Ryn-nY-yZp"/>
<constraint firstItem="89K-DQ-f8g" firstAttribute="centerY" secondItem="O1J-am-CoK" secondAttribute="centerY" id="Yeh-mY-trP"/>
<constraint firstItem="O1J-am-CoK" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="ZFA-S9-fpT"/>
<constraint firstAttribute="trailing" secondItem="QPM-sE-maP" secondAttribute="trailing" id="eOl-Va-HXq"/>
<constraint firstItem="QPM-sE-maP" firstAttribute="top" secondItem="O1J-am-CoK" secondAttribute="bottom" constant="10" id="leg-nD-mHB"/>
@@ -53,6 +63,7 @@
<collectionViewItem id="1Lb-iJ-Nar" customClass="DeviceListCell" customModule="QuickDropShareExtension" customModuleProvider="target">
<connections>
<outlet property="imageView" destination="O1J-am-CoK" id="zQn-mV-bRy"/>
<outlet property="peerMarkerView" destination="89K-DQ-f8g" id="iWY-ru-o1h"/>
<outlet property="textField" destination="QPM-sE-maP" id="s0j-Qq-7iA"/>
<outlet property="view" destination="Hz6-mo-xeY" id="gZn-20-o77"/>
</connections>