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.

Position marker: the classic navigation marker back as a style (arrow on a white disc); 3D arrow dropped; round markers drawn larger

CIS-C007517efadca7
diff --git a/app/src/main/java/com/rfsentinel/app/ui/MarkerArt.kt b/app/src/main/java/com/rfsentinel/app/ui/MarkerArt.kt
index f0f9f68..a1a5b88 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/MarkerArt.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/MarkerArt.kt
@@ -12,7 +12,7 @@ import android.graphics.Shader
import android.graphics.Color
/**
- * The position marker on the map (your arrow): a dot with a heading beam, an arrow (flat or 3D), or a car seen
+ * The position marker on the map (your arrow): the navigation arrow on a disc, a dot with a heading beam, an arrow, or a car seen
* from above, in a colour of your choice.
* Everything is drawn here in code on a 100 x 200 unit sheet with the front at the top, so any size is sharp and
* any colour works; the map turns it with your direction of travel. Pure drawing: the same function makes the
@@ -20,8 +20,9 @@ import android.graphics.Color
*/
object MarkerArt {
- enum class Style(val key: String, val label: String) {
- DOT("dot", "Classic dot"), ARROW("arrow", "Arrow"), ARROW_3D("arrow3d", "3D arrow"), CHEVRON("chevron", "Chevron"),
+ /** [scale]: how much bigger than the others it is drawn at the same size setting (the round ones fill only the sheet's width). */
+ enum class Style(val key: String, val label: String, val scale: Float = 1f) {
+ NAVIGATION("navigation", "Navigation", 1.7f), DOT("dot", "Classic dot", 1.4f), ARROW("arrow", "Arrow"), CHEVRON("chevron", "Chevron"),
SEDAN("sedan", "Sedan"), HATCHBACK("hatchback", "Hatchback"), WAGON("wagon", "Wagon"), SUV("suv", "SUV"),
PICKUP("pickup", "Pickup"), SPORTS("sports", "Sports car"), RACER("racer", "Racer"), CONVERTIBLE("convertible", "Convertible"),
MINI("mini", "Mini"), VAN("van", "Van"), TRUCK("truck", "Truck"), TAXI("taxi", "Taxi"), MOTORCYCLE("motorcycle", "Motorcycle");
@@ -63,9 +64,9 @@ object MarkerArt {
val c = Canvas(bmp)
c.scale(h / 200f, h / 200f)
when (style) {
+ Style.NAVIGATION -> navigation(c, color)
Style.DOT -> dot(c, color)
Style.ARROW -> arrow(c, color, ARROW)
- Style.ARROW_3D -> arrow3d(c, color)
Style.CHEVRON -> arrow(c, color, CHEVRON)
Style.SEDAN -> car(c, color, SEDAN)
Style.HATCHBACK -> car(c, color, HATCHBACK)
@@ -163,44 +164,25 @@ object MarkerArt {
}
/**
- * A navigation arrow with depth: a broad arrowhead lit from the left (two facets), standing on its own
- * thickness, so it reads as a solid piece lying on the road, also when the map is tilted.
+ * The map's classic navigation marker (as the map drew it before markers could be chosen): an arrow on a white
+ * disc in a faint halo, the arrow in your colour.
*/
- private fun arrow3d(c: Canvas, color: Int) {
- val top = floatArrayOf(50f, 18f, 90f, 168f, 50f, 138f, 10f, 168f)
- val depth = 14f
- val face = poly(top)
- // The ground shadow, below the solid.
- c.save(); c.translate(3f, depth + 6f)
- c.drawPath(face, fill(0x5C000000).apply { maskFilter = BlurMaskFilter(7f, BlurMaskFilter.Blur.NORMAL) })
+ private fun navigation(c: Canvas, color: Int) {
+ c.save()
+ // Drawn on a 75-unit square, centred on the sheet.
+ c.translate(0f, 50f); c.scale(100f / 75f, 100f / 75f)
+ c.drawCircle(37.5f, 37.5f, 37.5f, fill(0x29263D57))
+ c.drawCircle(37.5f, 38.5f, 28.5f, fill(0x40000000).apply { maskFilter = BlurMaskFilter(2.5f, BlurMaskFilter.Blur.NORMAL) })
+ c.drawCircle(37.5f, 37.5f, 28.5f, fill(0xFFFFFFFF.toInt()))
+ c.drawPath(NAV_ARROW, fill(color))
c.restore()
- // The solid: every edge swept down by the thickness, with the white rim around all of it.
- val solid = Path().apply {
- addPath(face); addPath(face, 0f, depth)
- var i = 0
- while (i < top.size) {
- val x1 = top[i]; val y1 = top[i + 1]; val x2 = top[(i + 2) % top.size]; val y2 = top[(i + 3) % top.size]
- addPath(Path().apply { moveTo(x1, y1); lineTo(x2, y2); lineTo(x2, y2 + depth); lineTo(x1, y1 + depth); close() })
- i += 2
- }
- }
- c.drawPath(solid, line(0xFFFFFFFF.toInt(), 8f))
- c.drawPath(solid, fill(0xFFFFFFFF.toInt()))
- c.drawPath(solid, Paint(Paint.ANTI_ALIAS_FLAG).apply {
- shader = LinearGradient(0f, 18f, 0f, 168f + depth, shade(color, 0.5f), shade(color, 0.34f), Shader.TileMode.CLAMP)
- })
- // The top: the left facet in the light, the right one in shade, a ridge down the middle.
- val left = Path().apply { moveTo(50f, 18f); lineTo(50f, 138f); lineTo(10f, 168f); close() }
- val right = Path().apply { moveTo(50f, 18f); lineTo(90f, 168f); lineTo(50f, 138f); close() }
- c.drawPath(left, Paint(Paint.ANTI_ALIAS_FLAG).apply {
- shader = LinearGradient(10f, 168f, 50f, 18f, lighten(color, 0.08f), lighten(color, 0.34f), Shader.TileMode.CLAMP)
- })
- c.drawPath(right, Paint(Paint.ANTI_ALIAS_FLAG).apply {
- shader = LinearGradient(90f, 168f, 50f, 18f, shade(color, 0.7f), shade(color, 0.9f), Shader.TileMode.CLAMP)
- })
- c.drawLine(50f, 20f, 50f, 136f, line(lighten(color, 0.5f), 1.6f))
- // The rim between the top and the sides.
- c.drawPath(face, line(lighten(color, 0.6f), 1.4f))
+ }
+
+ private val NAV_ARROW: Path by lazy {
+ androidx.core.graphics.PathParser.createPathFromPathData(
+ "M39.2,28.46C39.01,27.99 38.54,27.68 38.02,27.69C37.5,27.7 37.02,28.01 36.81,28.49L27.05,45.83C26.83,46.32 26.92,46.89 27.28,47.26" +
+ "C27.65,47.64 28.21,47.75 28.71,47.54L37.07,44.03C37.39,43.89 37.75,43.89 38.06,44.02L46.27,47.34C46.75,47.54 47.33,47.42 47.71,47.03" +
+ "C48.09,46.64 48.21,46.07 48,45.59L39.2,28.46Z")
}
// ---- cars --------------------------------------------------------------------------------------------
diff --git a/app/src/main/java/com/rfsentinel/app/ui/MarkerPicker.kt b/app/src/main/java/com/rfsentinel/app/ui/MarkerPicker.kt
index 22d2356..0876675 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/MarkerPicker.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/MarkerPicker.kt
@@ -41,7 +41,8 @@ object MarkerPicker {
/** The marker the map draws now. */
fun current(context: android.content.Context): android.graphics.Bitmap {
val c = effective(context)
- return MarkerArt.render(MarkerArt.Style.of(c.style), MarkerArt.colorOf(c.color).argb, heightPx(context, c.size))
+ val style = MarkerArt.Style.of(c.style)
+ return MarkerArt.render(style, MarkerArt.colorOf(c.color).argb, heightPx(context, c.size * style.scale))
}
/** "Sedan · Blue", for the Settings button. */
@@ -105,7 +106,7 @@ object MarkerPicker {
fun refresh() {
onChanged(Choice(style.key, color.key, size))
- val real = MarkerArt.render(style, color.argb, heightPx(activity, size))
+ val real = MarkerArt.render(style, color.argb, heightPx(activity, size * style.scale))
val show = if (real.height > px(BASE_DP * 2f)) MarkerArt.render(style, color.argb, px(BASE_DP * 2f)) else real
light.setImageDrawable(BitmapDrawable(activity.resources, show)); dark.setImageDrawable(BitmapDrawable(activity.resources, show))
val accent = ChipStyle.accent(activity).first
diff --git a/app/src/test/java/com/rfsentinel/app/ui/MarkerArtTest.kt b/app/src/test/java/com/rfsentinel/app/ui/MarkerArtTest.kt
index 717aaaf..6eeb13d 100644
--- a/app/src/test/java/com/rfsentinel/app/ui/MarkerArtTest.kt
+++ b/app/src/test/java/com/rfsentinel/app/ui/MarkerArtTest.kt
@@ -44,7 +44,7 @@ class MarkerArtTest {
fun theFrontIsAtTheTopOfEveryCarAndTheBackAtTheBottom() {
fun headlight(p: Int) = Color.red(p) > 235 && Color.green(p) > 225 && Color.blue(p) in 150..215 && Color.alpha(p) > 200
fun tail(p: Int) = Color.red(p) in 180..230 && Color.green(p) < 80 && Color.blue(p) < 80 && Color.alpha(p) > 200
- for (s in MarkerArt.Style.entries.filter { it !in listOf(MarkerArt.Style.DOT, MarkerArt.Style.ARROW, MarkerArt.Style.ARROW_3D, MarkerArt.Style.CHEVRON) }) {
+ for (s in MarkerArt.Style.entries.filter { it !in listOf(MarkerArt.Style.NAVIGATION, MarkerArt.Style.DOT, MarkerArt.Style.ARROW, MarkerArt.Style.CHEVRON) }) {
val b = MarkerArt.render(s, blue, 300)
val top = 0 until b.height / 4; val bottom = b.height * 3 / 4 until b.height
assertTrue("${s.key}: headlights at the front", count(b, top, ::headlight) > 20)
@@ -56,7 +56,7 @@ class MarkerArtTest {
@Test
fun anArrowPointsUp() {
- for (s in listOf(MarkerArt.Style.ARROW, MarkerArt.Style.ARROW_3D, MarkerArt.Style.CHEVRON)) {
+ for (s in listOf(MarkerArt.Style.ARROW, MarkerArt.Style.CHEVRON)) {
val b = MarkerArt.render(s, blue, 200)
// The tip is at the top, in the middle; the top corners are empty and the base is wide.
assertTrue(Color.alpha(b.getPixel(b.width / 2, 40)) > 200)
@@ -76,6 +76,18 @@ class MarkerArtTest {
assertEquals("nothing behind", 0, Color.alpha(b.getPixel(b.width / 2, 170)))
}
+ @Test
+ fun theNavigationMarkerIsAnArrowOnAWhiteDisc() {
+ val b = MarkerArt.render(MarkerArt.Style.NAVIGATION, blue, 300)
+ val cx = b.width / 2; val cy = b.height / 2
+ fun isBlue(p: Int) = Color.alpha(p) > 240 && Color.blue(p) > Color.red(p) + 80
+ fun isWhite(p: Int) = Color.alpha(p) > 240 && Color.red(p) > 240 && Color.blue(p) > 240
+ assertTrue("the arrow's tip is above the middle", isBlue(b.getPixel(cx, cy - 10)))
+ assertTrue("white disc beside the arrow", isWhite(b.getPixel(cx - 40, cy)))
+ assertTrue("white disc behind the arrow's notch", isWhite(b.getPixel(cx, cy + 30)))
+ assertTrue("a faint halo outside the disc", Color.alpha(b.getPixel(cx, cy + 70)) in 20..120)
+ }
+
@Test
fun theColourChangesTheMarker() {
val a = MarkerArt.render(MarkerArt.Style.SEDAN, MarkerArt.colorOf("red").argb, 200)