Skip to content

RF Sentinel (RFSentinel): free, open-source police detector app for Android. Spots police body cams, Flock ALPR cameras, AirTag trackers, Remote ID drones, smart glasses and fake cell towers from Bluetooth LE and WiFi. No root.

Grouped list: headers keep their place as counts change; aircraft, radio, Waze and cell towers get groups too, urgent ones under Alerts

CIS-C02289dc223a07
diff --git a/app/src/main/java/com/rfsentinel/app/MainActivity.kt b/app/src/main/java/com/rfsentinel/app/MainActivity.kt
index 10e2938..c5c647f 100644
--- a/app/src/main/java/com/rfsentinel/app/MainActivity.kt
+++ b/app/src/main/java/com/rfsentinel/app/MainActivity.kt
@@ -738,11 +738,23 @@ class MainActivity : AppCompatActivity() {
val (urgent, quiet) = waze.partition { it.flashing }
val (radioLive, radioOld) = radio.partition { it.flashing }
val (airUrgent, airQuiet) = air.partition { it.flashing }
- val deviceRows = sections.flatMap { sec ->
- listOfNotNull(sec.header?.let { DeviceRow.header(com.rfsentinel.app.ui.DeviceOrder.headerLabel(sec)) }) +
- sec.items.map { toRow(it, now, threshold) }
+ if (com.rfsentinel.app.ui.DeviceOrder.group(this) == com.rfsentinel.app.ui.DeviceOrder.Group.NONE) {
+ submitRows(airUrgent + radioLive + urgent + sections.flatMap { it.items }.map { toRow(it, now, threshold) } +
+ airQuiet + radioOld + cells + quiet)
+ } else {
+ // Grouped: everything the list shows has a group, not only Bluetooth and WiFi devices. What's
+ // urgent (Waze, radio, aircraft) joins the flagged devices in Alerts, at the top.
+ fun block(key: String, label: String, rows: List<DeviceRow>) =
+ if (rows.isEmpty()) emptyList() else listOf(DeviceRow.header(key, "$label · ${rows.size}")) + rows
+ val alerts = com.rfsentinel.app.ui.DeviceOrder.ALERTS
+ submitRows(
+ block(alerts, alerts, airUrgent + radioLive + urgent +
+ sections.filter { it.header == alerts }.flatMap { it.items }.map { toRow(it, now, threshold) }) +
+ sections.filter { it.header != alerts }.flatMap { sec -> block(sec.header.orEmpty(), sec.header.orEmpty(), sec.items.map { toRow(it, now, threshold) }) } +
+ block("x:aircraft", "Aircraft", airQuiet) + block("x:radio", "Radio transmissions", radioOld) +
+ block("x:waze", "Waze reports", quiet) + block("x:cells", "Cell towers", cells)
+ )
}
- submitRows(airUrgent + radioLive + urgent + deviceRows + airQuiet + radioOld + cells + quiet)
shownCells = cells.size + waze.size + radio.size + air.size
}
binding.emptyState.visibility = if (visible.isEmpty() && (!panes.listShown || shownCells == 0) &&
diff --git a/app/src/main/java/com/rfsentinel/app/ui/DeviceAdapter.kt b/app/src/main/java/com/rfsentinel/app/ui/DeviceAdapter.kt
index ffa4277..1e40552 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/DeviceAdapter.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/DeviceAdapter.kt
@@ -41,7 +41,8 @@ data class DeviceRow(
val header: Boolean = false
) {
companion object {
- fun header(label: String) = DeviceRow("header:$label", label, "", "", null, 0, null, false, true, header = true)
+ /** Keyed by the group ([key]), not its label: the count changing must not swap the row (it flickered). */
+ fun header(key: String, label: String) = DeviceRow("header:$key", label, "", "", null, 0, null, false, true, header = true)
}
}
diff --git a/app/src/main/java/com/rfsentinel/app/ui/DeviceOrder.kt b/app/src/main/java/com/rfsentinel/app/ui/DeviceOrder.kt
index 6192279..f9853fc 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/DeviceOrder.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/DeviceOrder.kt
@@ -52,6 +52,8 @@ object DeviceOrder {
DeviceFilter.TRACKERS, DeviceFilter.DRONES, DeviceFilter.CAMERAS, DeviceFilter.VEHICLES, DeviceFilter.PHONES,
DeviceFilter.AUDIO, DeviceFilter.ROUTERS, DeviceFilter.HOTSPOTS, DeviceFilter.TVS, DeviceFilter.SMART_HOME
)
+ /** The group of flagged devices, first when grouped. */
+ const val ALERTS = "Alerts"
private const val OTHER = "Other"
private const val UNKNOWN_MAKER = "Unknown maker"
private val BANDS = listOf("Near", "Nearby", "Far")
@@ -83,7 +85,7 @@ object DeviceOrder {
// Most common makers first, unknown last.
else -> groups.keys.sortedWith(compareBy<String> { it == UNKNOWN_MAKER }.thenByDescending { groups[it]!!.size }.thenBy { it.lowercase() })
}
- return listOfNotNull(alerts.takeIf { it.isNotEmpty() }?.let { Section("Alerts", it.map { a -> a.value }) }) +
+ return listOfNotNull(alerts.takeIf { it.isNotEmpty() }?.let { Section(ALERTS, it.map { a -> a.value }) }) +
keys.map { k -> Section(k, groups.getValue(k).map { it.value }) }
}