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.

Mapbox map: logo and info button at the very top, credit line beside them, scale underneath

CIS-C0b4b4c679b93b
diff --git a/app/src/full/java/com/rfsentinel/app/ui/MapboxEngine.kt b/app/src/full/java/com/rfsentinel/app/ui/MapboxEngine.kt
index 7220f3d..f4ee5aa 100644
--- a/app/src/full/java/com/rfsentinel/app/ui/MapboxEngine.kt
+++ b/app/src/full/java/com/rfsentinel/app/ui/MapboxEngine.kt
@@ -356,6 +356,9 @@ internal class MapboxEngine(private val context: Context) : MapEngine {
vp.transitionTo(state, transition, null)
}
+ // Mapbox's logo (8 dp in) and its info button (96 dp in), as the SDK draws them; their size can't be changed.
+ override val brandingDp = 122f to 22f
+
private var brandingTop = -1
private var brandingAtEnd = false
diff --git a/app/src/main/java/com/rfsentinel/app/ui/MapEngine.kt b/app/src/main/java/com/rfsentinel/app/ui/MapEngine.kt
index f263017..9bdd093 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/MapEngine.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/MapEngine.kt
@@ -110,8 +110,10 @@ internal interface MapEngine {
fun follow(mode: Follow, topPaddingPx: Double?, tilt: Double, zoom: Double?, ms: Long)
/** You panned away: the map stopped following. */
var onFollowDismissed: (() -> Unit)?
- /** Where the provider's logo and info button go (Mapbox: under the credit line). */
+ /** Where the provider's logo and info button go: their top edge, at the start or (with [atEnd]) the end. */
fun placeBranding(topPx: Int, atEnd: Boolean = false)
+ /** The room the logo and info button take, in dp (width from the edge, height); none for a provider without them. */
+ val brandingDp: Pair<Float, Float> get() = 0f to 0f
companion object {
/** Mapbox needs the full build (the FOSS build leaves its SDK out) and a token in local.properties. */
diff --git a/app/src/main/java/com/rfsentinel/app/ui/MapFragment.kt b/app/src/main/java/com/rfsentinel/app/ui/MapFragment.kt
index 27b530b..817b201 100644
--- a/app/src/main/java/com/rfsentinel/app/ui/MapFragment.kt
+++ b/app/src/main/java/com/rfsentinel/app/ui/MapFragment.kt
@@ -509,9 +509,20 @@ class MapFragment : Fragment() {
// to the free top right corner instead of being hidden under the bar.
val atEnd = wideScreen() && Navigator.active
val y = (if (atEnd) box.translationY.toInt() + gap / 2 else if (box.height > 0) box.bottom + box.translationY.toInt() + gap else box.top + box.translationY.toInt()).coerceAtLeast(gap)
- b.scaleBar.translationY = y.toFloat()
// The credit wraps to a second line rather than run under the compass and follow buttons at the right.
val d = resources.displayMetrics.density
+ val (brandW, brandH) = engine?.brandingDp ?: (0f to 0f)
+ if (brandW > 0f && !atEnd) {
+ // Mapbox: its logo and info button at the very top, the credit line beside them, the scale under them.
+ val rowH = (brandH * d).toInt()
+ engine?.placeBranding(y, false)
+ if (b.root.width > 0) b.osmCredit.maxWidth = (b.root.width - 84 * d - brandW * d).toInt().coerceAtLeast((100 * d).toInt())
+ b.osmCredit.translationX = brandW * d - b.osmCredit.left
+ b.osmCredit.translationY = (y + (rowH - b.osmCredit.height) / 2).toFloat()
+ b.scaleBar.translationY = (y + maxOf(rowH, b.osmCredit.height) + gap / 2).toFloat()
+ return
+ }
+ b.scaleBar.translationY = y.toFloat()
if (b.root.width > 0) b.osmCredit.maxWidth = (b.root.width - 84 * d).toInt().coerceAtLeast((140 * d).toInt())
val scaleH = if (b.scaleBar.visibility == View.GONE) 0 else b.scaleBar.height
b.osmCredit.translationY = (y + scaleH).toFloat()