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.
Kotlin airtagalprandroidandroid-autoanti-surveillancebluetooth-low-energybody-cameracounter-surveillancedrone-detectionflock-safetyimsi-catcher-detectorpolice-detectorpolice-scannerprivacyremote-idrtl-sdrsdrsurveillance-detectiontracker-detectionwifi
One filter for the main screen and the map; map Aircraft filter shows every plane clearly; no doubled title on styled headers
CIS-C0416a27422198
diff --git a/app/src/main/java/com/rfsentinel/app/MainActivity.kt b/app/src/main/java/com/rfsentinel/app/MainActivity.ktindex 5fde52d..f722b36 100644--- a/app/src/main/java/com/rfsentinel/app/MainActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/MainActivity.kt@@ -191,6 +191,8 @@ class MainActivity : AppCompatActivity() {}}.show()}+ // One filter for this screen and the full screen map: the last one picked on either.+ filter = com.rfsentinel.app.ui.DeviceFilter.parse(Prefs.mapFilter(this))setupFilterChips()panes.setFilter(filter)@@ -219,6 +221,14 @@ class MainActivity : AppCompatActivity() {com.rfsentinel.app.ui.DemoData.seedAlerts(this@MainActivity, anchor)anchor?.let { com.rfsentinel.app.ui.DemoData.seedHistory(this@MainActivity, it) }}+ // Made-up aircraft drifting around, for the list, the map and its Aircraft filter.+ lifecycleScope.launch {+ while (true) {+ com.rfsentinel.app.online.PoliceAircraft.latest = com.rfsentinel.app.ui.DemoData.aircraft(anchor ?: (0.0 to 0.0))+ com.rfsentinel.app.online.PoliceAircraft.latestAt = System.currentTimeMillis()+ kotlinx.coroutines.delay(2_000L)+ }+ }// --ez demo_alert true: a made-up alert every 12 s, for the alert card on the full screen map.if (intent.getBooleanExtra("demo_alert", false)) lifecycleScope.launch {while (true) { kotlinx.coroutines.delay(12_000L); com.rfsentinel.app.ui.DemoData.publishSampleAlert(com.rfsentinel.app.ui.DemoData.fakeLocation?.let { it.latitude to it.longitude }) }@@ -236,6 +246,10 @@ class MainActivity : AppCompatActivity() {override fun onResume() {super.onResume()+ // Back from the full screen map: show the filter picked there.+ com.rfsentinel.app.ui.DeviceFilter.parse(Prefs.mapFilter(this)).let { f ->+ if (f != filter) filterChips[f]?.let { it.isChecked = true; scrollToChip(it) }+ }updateStatus()// Every time the app comes to the front (this screen can stay alive for days): Settings > Check for updates on app open.if (Prefs.onboardingDone(this)) com.rfsentinel.app.util.UpdateChecker.checkOnStartup(this)@@ -258,6 +272,8 @@ class MainActivity : AppCompatActivity() {// A custom theme can have just a banner and no animated header.binding.themedHeader.visibility = if (header != null || ownBanner) View.VISIBLE else View.GONEbinding.themeHeader.visibility = if (header != null) View.VISIBLE else View.GONE+ // The styled headers draw the app's name themselves: no second title over it in the title bar.+ supportActionBar?.setDisplayShowTitleEnabled(header == null)if (header == null && !ownBanner) returnif (header != null) binding.themeHeader.style = headerval file = com.rfsentinel.app.ui.ThemeManager.bannerFile(this)@@ -308,15 +324,22 @@ class MainActivity : AppCompatActivity() {}filterChips[f] = chipbinding.filterChips.addView(chip)- if (f == filter) chip.isChecked = true+ if (f == filter) { chip.isChecked = true; scrollToChip(chip) }}binding.filterChips.setOnCheckedStateChangeListener { _, ids ->filter = filterChips.entries.firstOrNull { it.value.id == ids.firstOrNull() }?.key ?: return@setOnCheckedStateChangeListener+ Prefs.setMapFilter(this, filter.name)panes.setFilter(filter)render()}}+ /** Brings [chip] into view in the sideways-scrolling row (a filter picked on the map may be past the edge). */+ private fun scrollToChip(chip: com.google.android.material.chip.Chip) {+ val row = binding.filterChips.parent as? android.widget.HorizontalScrollView ?: return+ row.post { if (chip.right > row.scrollX + row.width || chip.left < row.scrollX) row.smoothScrollTo((chip.left - row.width / 4).coerceAtLeast(0), 0) }+ }+/** The stock chip's side paddings, to put back in the list style. */private var chipPadding: FloatArray? = null@@ -739,9 +762,8 @@ class MainActivity : AppCompatActivity() {}}- /** The aircraft heard right now (RTL-SDR ADS-B and the online feeds); made-up ones in the demo. */+ /** The aircraft heard right now (RTL-SDR ADS-B and the online feeds). */private fun currentAircraft(now: Long): List<com.rfsentinel.app.online.PoliceAircraft.Seen> = when {- demoMode -> com.rfsentinel.app.ui.DemoData.aircraft(com.rfsentinel.app.ui.DemoData.fakeLocation?.let { it.latitude to it.longitude } ?: (0.0 to 0.0))!ScanForegroundService.isRunning -> emptyList()else -> com.rfsentinel.app.online.PoliceAircraft.all(now)}diff --git a/app/src/main/java/com/rfsentinel/app/ui/MapFragment.kt b/app/src/main/java/com/rfsentinel/app/ui/MapFragment.ktindex f7b2b37..50b6b07 100644--- a/app/src/main/java/com/rfsentinel/app/ui/MapFragment.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/MapFragment.kt@@ -1210,7 +1210,8 @@ class MapFragment : Fragment() {filter = DeviceFilter.ALLreturn}- val options = if (tripId == null) DeviceFilter.entries.filter { it != DeviceFilter.RADIO } else listOf(DeviceFilter.ALL, DeviceFilter.FLAGGED)+ // The main screen's order; the choice is shared with it (a trace's own map keeps its own).+ val options = if (tripId == null) DeviceFilter.MAIN_ORDER.filter { it != DeviceFilter.RADIO } else listOf(DeviceFilter.ALL, DeviceFilter.FLAGGED)filter = DeviceFilter.parse(Prefs.mapFilter(act)).takeIf { it in options } ?: DeviceFilter.ALLval group = binding.mapFilterChipsfor (f in options) {@@ -1229,9 +1230,26 @@ class MapFragment : Fragment() {val picked = filterChips.entries.firstOrNull { it.value.id == ids.firstOrNull() }?.key ?: return@setOnCheckedStateChangeListenerfilter = pickedrf?.filter = picked- Prefs.setMapFilter(act, picked.name)+ if (tripId == null) Prefs.setMapFilter(act, picked.name)if (tripId != null) loadTrip() else renderLive()rf?.safe("static") { rf?.maybeRedrawStatic(force = true) }+ if (picked == DeviceFilter.AIRCRAFT && tripId == null) frameAircraft()+ }+ }++ /** The Aircraft filter: stops following you and zooms out to show every aircraft (and you). */+ private fun frameAircraft() {+ val m = map ?: return+ val air = com.rfsentinel.app.online.PoliceAircraft.all().map { it.plane.lat to it.plane.lon }+ if (air.isEmpty()) {+ Toast.makeText(act, "No aircraft in range right now", Toast.LENGTH_SHORT).show()+ return+ }+ if (following) { following = false; applyMode(animate = false); styleFollowButton() }+ val pts = air + listOfNotNull(myPosition())+ rf?.safe("frame") {+ if (pts.size == 1) m.jumpTo(pts[0].first, pts[0].second, 11.0 - ZOOM_SHIFT)+ else m.fit(pts, (56 * resources.displayMetrics.density).toInt())}}@@ -1243,6 +1261,7 @@ class MapFragment : Fragment() {DeviceFilter.CELLS -> rf?.towerCount ?: 0DeviceFilter.WAZE -> com.rfsentinel.app.online.WazePolice.latest.sizeDeviceFilter.AIRCRAFT -> com.rfsentinel.app.online.PoliceAircraft.all().size+ DeviceFilter.RADIO -> 0else -> placed.count { f.matches(it) }}chip.text = if (f == DeviceFilter.ALL || n > 0) "${f.label} $n" else f.labeldiff --git a/app/src/main/java/com/rfsentinel/app/ui/MapIcons.kt b/app/src/main/java/com/rfsentinel/app/ui/MapIcons.ktindex 9226be2..ffed3e6 100644--- a/app/src/main/java/com/rfsentinel/app/ui/MapIcons.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/MapIcons.kt@@ -68,13 +68,16 @@ object MapIcons {}const val POLICE_AIRCRAFT_COLOR = 0xFF5E35B1.toInt()+ /** Other aircraft under the map's Aircraft filter. */+ const val CLEAR_AIRCRAFT_COLOR = 0xFF1E88E5.toInt()/*** An aircraft seen from above, nose up (the marker rotates it to its track). Police /- * government aircraft: bold purple with a white outline; other traffic: small and grey.+ * government aircraft: bold purple with a white outline; other traffic: small and grey, or+ * [clear] (the map's Aircraft filter): larger, solid blue with a white outline.*/- fun planeIcon(dp: Float, police: Boolean, scale: Float = 1f): Bitmap {- val s = ((if (police) 30 else 18) * dp * scale).toInt().coerceAtLeast(8)+ fun planeIcon(dp: Float, police: Boolean, scale: Float = 1f, clear: Boolean = false): Bitmap {+ val s = ((if (police) 30 else if (clear) 26 else 18) * dp * scale).toInt().coerceAtLeast(8)val bmp = Bitmap.createBitmap(s, s, Bitmap.Config.ARGB_8888)val c = Canvas(bmp)val w = s.toFloat()@@ -98,12 +101,12 @@ object MapIcons {close()}val p = Paint(Paint.ANTI_ALIAS_FLAG)- p.color = if (police) POLICE_AIRCRAFT_COLOR else 0xB3707C80.toInt()+ p.color = if (police) POLICE_AIRCRAFT_COLOR else if (clear) CLEAR_AIRCRAFT_COLOR else 0xB3707C80.toInt()c.drawPath(path, p)p.style = Paint.Style.STROKEp.strokeJoin = Paint.Join.ROUND- p.strokeWidth = (if (police) 1.8f else 1f) * dp * scale.coerceIn(0.7f, 1.5f)- p.color = if (police) Color.WHITE else 0xCCFFFFFF.toInt()+ p.strokeWidth = (if (police || clear) 1.8f else 1f) * dp * scale.coerceIn(0.7f, 1.5f)+ p.color = if (police || clear) Color.WHITE else 0xCCFFFFFF.toInt()c.drawPath(path, p)return bmp}diff --git a/app/src/main/java/com/rfsentinel/app/ui/RfMap.kt b/app/src/main/java/com/rfsentinel/app/ui/RfMap.ktindex 81b7dda..9790491 100644--- a/app/src/main/java/com/rfsentinel/app/ui/RfMap.kt+++ b/app/src/main/java/com/rfsentinel/app/ui/RfMap.kt@@ -127,6 +127,7 @@ internal class RfMap(private val activity: AppCompatActivity, val map: MapEnginemap.addImage("rf-cctv-private", MapIcons.cctvIcon(dp, true))map.addImage("rf-plane-police", MapIcons.planeIcon(dp, true))map.addImage("rf-plane", MapIcons.planeIcon(dp, false))+ map.addImage("rf-plane-clear", MapIcons.planeIcon(dp, false, clear = true))map.addImage("rf-tower", MapIcons.towerIcon(dp))map.addImage("rf-drone", droneArrow(dp))}@@ -200,18 +201,20 @@ internal class RfMap(private val activity: AppCompatActivity, val map: MapEngine"circle-stroke-color" to DRONE_COLOR, "circle-stroke-width" to 2.0)),layer(DRONES, "symbol", layout = o("icon-image" to "rf-drone", "icon-rotate" to get("dir"),"icon-rotation-alignment" to "map", *overlap)),- // Aircraft: police / government ones bold purple with their agency and altitude, others small and grey.+ // Aircraft: police / government ones bold purple with their agency and altitude, others small and grey+ // (under the Aircraft filter: every one large and labelled).// Where the route ends (red) and the stops on the way (white with a blue edge), above everything else.layer("$NAV_PLACES-pin", "circle", NAV_PLACES, paint = o("circle-color" to a("case", a("==", get("end"), true), "#D93025", "#FFFFFF"), "circle-radius" to 9.0,"circle-stroke-color" to a("case", a("==", get("end"), true), "#FFFFFF", NAV_ROUTE_COLOR), "circle-stroke-width" to 3.0)),layer(AIRCRAFT, "symbol", layout = o("icon-image" to get("icon"), "icon-rotate" to get("track"),"icon-rotation-alignment" to "map",- "icon-size" to a("interpolate", a("linear"), a("zoom"), 9, 0.5, 12, 1.0, 16, 2.0),+ "icon-size" to a("interpolate", a("linear"), a("zoom"), 9, a("case", a("==", get("clear"), true), 1.0, 0.5), 12, 1.0, 16, 2.0),*overlap, "symbol-sort-key" to a("case", flagged, 1.0, 0.0),"text-field" to get("label"), "text-font" to font, "text-size" to 12.0, "text-anchor" to "top","text-offset" to a(0.0, 1.6), "text-optional" to true),- paint = o("text-color" to "#FFFFFF", "text-halo-color" to hex(MapIcons.POLICE_AIRCRAFT_COLOR), "text-halo-width" to 3.0))+ paint = o("text-color" to "#FFFFFF", "text-halo-color" to a("case", flagged, hex(MapIcons.POLICE_AIRCRAFT_COLOR),+ hex(MapIcons.CLEAR_AIRCRAFT_COLOR)), "text-halo-width" to 3.0))).forEach { map.addLayer(it) }}@@ -294,13 +297,17 @@ internal class RfMap(private val activity: AppCompatActivity, val map: MapEngineval air = PoliceAircraft.all()planes = air.associateBy { it.plane.hex }+ val clear = filter == DeviceFilter.AIRCRAFTset(AIRCRAFT, air.map { (p, hit) ->GeoJson.feature(GeoJson.point(p.lat, p.lon),"hex" to p.hex,- "icon" to if (hit != null) "rf-plane-police" else "rf-plane",+ "icon" to if (hit != null) "rf-plane-police" else if (clear) "rf-plane-clear" else "rf-plane","track" to (p.trackDeg ?: 0.0),"flagged" to (hit != null),- "label" to if (hit == null) "" else listOfNotNull(+ "clear" to clear,+ "label" to if (hit == null) {+ if (clear) listOfNotNull(AircraftActivity.name(p), AircraftActivity.altitude(p)).joinToString(" · ") else ""+ } else listOfNotNull(hit.label.substringAfter(": ", hit.label).take(28), p.altitudeFt?.takeIf { it > 0 }?.let { "$it ft" }).joinToString(" · "))})