feat: sort device list while keeping None (Disabled) at the top of the list (#1309)

Signed-off-by: Matthew Bogner <matt@ibogner.net>
This commit is contained in:
Matthew Bogner
2024-10-13 06:23:55 -05:00
committed by GitHub
parent 86dc8f2b1c
commit df7ce09fdb

View File

@@ -360,7 +360,11 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
if (devices == null) return
var hasShownOurDevice = false
devices.values.forEach { device ->
devices.values
// Display the device list in alphabetical order while keeping the "None (Disabled)"
// device (fullAddress == n) at the top
.sortedBy { dle -> if (dle.fullAddress == "n") "0" else dle.name }
.forEach { device ->
if (device.fullAddress == scanModel.selectedNotNull)
hasShownOurDevice = true
addDeviceButton(device, true)