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.

Map: aircraft icons scale with the zoom

CIS-C0157559363533
diff --git a/app/src/main/java/com/rfsentinel/app/ui/MapActivity.kt b/app/src/main/java/com/rfsentinel/app/ui/MapActivity.kt
index 34057a2..e7672c3 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/MapActivity.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/MapActivity.kt
@@ -95,6 +95,7 @@ class MapActivity : AppCompatActivity() {
private val drones = FolderOverlay()
/** Aircraft from the ADS-B feeds (Settings > What to detect > Police / government aircraft). */
private val aircraft = FolderOverlay()
+ private var planeZoomStep = -1
/** Plate-reader cameras mapped in OpenStreetMap (downloaded on request). */
private val knownAlpr by lazy {
PointsOverlay<com.rfsentinel.app.alpr.KnownCamera>(resources.displayMetrics.density) { showKnownCamera(it.first()) }
@@ -188,6 +189,9 @@ class MapActivity : AppCompatActivity() {
}
override fun onZoom(event: org.osmdroid.events.ZoomEvent?) = false.also {
drawKnownAlprSoon()
+ // Plane icons grow as you zoom in (and shrink as you zoom out).
+ val step = kotlin.math.round(binding.map.zoomLevelDouble * 2).toInt()
+ if (step != planeZoomStep) { planeZoomStep = step; drawAircraft() }
}
})
@@ -529,16 +533,20 @@ class MapActivity : AppCompatActivity() {
*/
private fun drawAircraft() {
aircraft.items.clear()
+ binding.map.invalidate()
val list = com.rfsentinel.app.online.PoliceAircraft.latest
if (list.isEmpty() || System.currentTimeMillis() - com.rfsentinel.app.online.PoliceAircraft.latestAt > 3 * 60_000L) return
val dp = resources.displayMetrics.density
+ // Sized to the zoom: 0.5x at a city-wide view (zoom 10), 1x at zoom 13, 2.2x at street level (17+).
+ val scale = (0.5 + (binding.map.zoomLevelDouble - 10.0) * (1.7 / 7.0)).coerceIn(0.5, 2.2).toFloat()
+ val icons = HashMap<Boolean, android.graphics.drawable.BitmapDrawable>()
// Ordinary traffic first, so flagged aircraft are drawn on top.
for ((p, hit) in list.sortedBy { it.hit != null }) {
val flagged = hit != null
val at = GeoPoint(p.lat, p.lon)
aircraft.add(Marker(binding.map).apply {
position = at
- icon = android.graphics.drawable.BitmapDrawable(resources, MapIcons.planeIcon(dp, flagged))
+ icon = icons.getOrPut(flagged) { android.graphics.drawable.BitmapDrawable(resources, MapIcons.planeIcon(dp, flagged, scale)) }
rotation = -(p.trackDeg ?: 0.0).toFloat() // osmdroid rotates counter-clockwise
isFlat = true
setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_CENTER)
diff --git a/app/src/main/java/com/rfsentinel/app/ui/MapIcons.kt b/app/src/main/java/com/rfsentinel/app/ui/MapIcons.kt
index 1217e1f..011ad29 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/MapIcons.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/MapIcons.kt
@@ -51,8 +51,8 @@ object MapIcons {
* 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.
*/
- fun planeIcon(dp: Float, police: Boolean): Bitmap {
- val s = ((if (police) 30 else 18) * dp).toInt()
+ fun planeIcon(dp: Float, police: Boolean, scale: Float = 1f): Bitmap {
+ val s = ((if (police) 30 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()
@@ -80,7 +80,7 @@ object MapIcons {
c.drawPath(path, p)
p.style = Paint.Style.STROKE
p.strokeJoin = Paint.Join.ROUND
- p.strokeWidth = (if (police) 1.8f else 1f) * dp
+ p.strokeWidth = (if (police) 1.8f else 1f) * dp * scale.coerceIn(0.7f, 1.5f)
p.color = if (police) Color.WHITE else 0xCCFFFFFF.toInt()
c.drawPath(path, p)
return bmp