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
Settings › Alerts: choose what swiping a flagged row right and left does (mute / unmute, hide, none)
CIS-C0eb02032bfe25
diff --git a/app/src/main/java/com/rfsentinel/app/MainActivity.kt b/app/src/main/java/com/rfsentinel/app/MainActivity.ktindex e0e2d6e..5fa21aa 100644--- a/app/src/main/java/com/rfsentinel/app/MainActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/MainActivity.kt@@ -1105,7 +1105,19 @@ class MainActivity : AppCompatActivity() {render()}- /** Swipe a flagged row: right mutes it (as its button does), left dismisses or hides it ([hideRow]). Each with Undo. */+ /** What swiping [r] right or left does (Settings › Alerts), or null for nothing: aircraft and radio rows have no mute. */+ private fun swipeAction(r: DeviceRow, right: Boolean): String? {+ val noMute = r.mac.startsWith(AIRCRAFT_ROW) || r.mac.startsWith(RADIO_ROW)+ return Prefs.swipeAction(this, right).takeIf {+ when (it) {+ "mute" -> r.canMute && !noMute+ "hide" -> r.canMute || noMute+ else -> false+ }+ }+ }++ /** Swipe a flagged row: mute it (as its button does) or dismiss / hide it ([hideRow], with Undo), as set for each side. */private fun attachRowSwipes() {val dp = resources.displayMetrics.densityval paint = android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG).apply {@@ -1118,11 +1130,7 @@ class MainActivity : AppCompatActivity() {private fun row(vh: androidx.recyclerview.widget.RecyclerView.ViewHolder) = adapter.currentList.getOrNull(vh.bindingAdapterPosition)override fun getSwipeDirs(rv: androidx.recyclerview.widget.RecyclerView, vh: androidx.recyclerview.widget.RecyclerView.ViewHolder): Int {val r = row(vh) ?: return 0- return when {- r.mac.startsWith(AIRCRAFT_ROW) || r.mac.startsWith(RADIO_ROW) -> swipeLeft // no mute button on these rows: hide or dismiss only- r.canMute -> swipeLeft or swipeRight- else -> 0- }+ return (if (swipeAction(r, true) != null) swipeRight else 0) or (if (swipeAction(r, false) != null) swipeLeft else 0)}override fun onMove(rv: androidx.recyclerview.widget.RecyclerView, a: androidx.recyclerview.widget.RecyclerView.ViewHolder,b: androidx.recyclerview.widget.RecyclerView.ViewHolder) = false@@ -1132,19 +1140,23 @@ class MainActivity : AppCompatActivity() {helper.attachToRecyclerView(null); helper.attachToRecyclerView(binding.recyclerView)val r = row(vh) ?: returnadapter.notifyItemChanged(vh.bindingAdapterPosition) // a hidden row then leaves with the next list- if (direction == swipeRight) toggleMute(r, false) else hideRow(r)+ when (swipeAction(r, direction == swipeRight)) {+ "mute" -> toggleMute(r, false)+ "hide" -> hideRow(r)+ }}override fun onChildDraw(c: android.graphics.Canvas, rv: androidx.recyclerview.widget.RecyclerView, vh: androidx.recyclerview.widget.RecyclerView.ViewHolder,dX: Float, dY: Float, state: Int, active: Boolean) {val v = vh.itemViewif (dX != 0f) {val right = dX > 0- paint.color = if (right) accent else com.rfsentinel.app.ui.ThemeManager.ink(this@MainActivity, WHITELIST_COLOR)+ val r = row(vh)+ val mute = r != null && swipeAction(r, right) == "mute"+ paint.color = if (mute) accent else com.rfsentinel.app.ui.ThemeManager.ink(this@MainActivity, WHITELIST_COLOR)if (right) c.drawRect(v.left.toFloat(), v.top.toFloat(), v.left + dX, v.bottom.toFloat(), paint)else c.drawRect(v.right + dX, v.top.toFloat(), v.right.toFloat(), v.bottom.toFloat(), paint)- paint.color = if (right) onAccent else android.graphics.Color.WHITE- val r = row(vh)- val label = if (!right) (if (r != null && hidesWhole(r)) "Hide" else "Dismiss") else if (r?.muted == true) "Unmute" else "Mute"+ paint.color = if (mute) onAccent else android.graphics.Color.WHITE+ val label = if (mute) (if (r?.muted == true) "Unmute" else "Mute") else if (r != null && hidesWhole(r)) "Hide" else "Dismiss"val y = (v.top + v.bottom) / 2f - (paint.descent() + paint.ascent()) / 2if (right) c.drawText(label, v.left + 20 * dp, y, paint)else c.drawText(label, v.right - 20 * dp - paint.measureText(label), y, paint)diff --git a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.ktindex e9768db..1ed802f 100644--- a/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt+++ b/app/src/main/java/com/rfsentinel/app/settings/SettingsActivity.kt@@ -1527,32 +1527,52 @@ class SettingsActivity : AppCompatActivity() {v === binding.vibrateSwitch || (v as? android.view.ViewGroup)?.indexOfChild(binding.vibrateSwitch)?.let { it >= 0 } == true} ?: returnval choices = Prefs.SNOOZE_CHOICES+ val row = choiceRow("Snooze length", choices.map { "$it min" }, choices.indexOf(Prefs.snoozeMinutes(this))) {+ Prefs.setSnoozeMinutes(this, choices[it])+ }+ section.addView(infoRow(row, "How long a snooze silences the alert sound and voice, like a radar detector's mute: the " ++ "speaker button at the top of the main screen (tap it), Mute on an alert notification, and the car's snooze. " ++ "Alerts still show on screen and in the list while snoozed. Long-press the speaker button for other lengths or " ++ "to mute until you turn the sound back on.", "Snooze length"), at + 1)+ // Under it: what a swipe on a flagged row of the main list does, each side.+ val actions = Prefs.SWIPE_ACTIONS+ for ((i, right) in listOf(true, false).withIndex()) {+ val label = if (right) "Swipe right on an alert" else "Swipe left on an alert"+ val swipe = choiceRow(label, listOf("Mute / unmute", "Hide", "None"), actions.indexOf(Prefs.swipeAction(this, right))) {+ Prefs.setSwipeAction(this, right, actions[it])+ }+ section.addView(infoRow(swipe, "What swiping a flagged row of the main list does. Both sides can do the same thing.\n\n" ++ "Mute / unmute: no alerts from it for 30 min, as its mute button; swiped again, alerts are back on.\n\n" ++ "Hide: a flagged device or radio transmission stays listed as an ordinary one, a Waze report or an aircraft " ++ "leaves the list. No alerts from it for 30 min or until the scan stops, then it comes back as it was. " ++ "Undo at the bottom puts it back at once.\n\n" ++ "None: that swipe does nothing. Aircraft and radio rows have no mute: only Hide works on them.", label), at + 2 + i)+ }+ }++ /** A setting's label with a drop-down of [items] on its right (Snooze length, the swipes); [onPick] gets the index. */+ private fun choiceRow(label: String, items: List<String>, selected: Int, onPick: (Int) -> Unit): View {val row = android.widget.LinearLayout(this).apply {orientation = android.widget.LinearLayout.HORIZONTALgravity = android.view.Gravity.CENTER_VERTICALminimumHeight = (48 * resources.displayMetrics.density).toInt()}row.addView(android.widget.TextView(this).apply {- text = "Snooze length"+ text = labelsetTextAppearance(android.R.style.TextAppearance_Material_Body1)}, android.widget.LinearLayout.LayoutParams(0, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT, 1f))row.addView(androidx.appcompat.widget.AppCompatSpinner(this).apply {- adapter = android.widget.ArrayAdapter(this@SettingsActivity, android.R.layout.simple_spinner_item, choices.map { "$it min" }).also {+ adapter = android.widget.ArrayAdapter(this@SettingsActivity, android.R.layout.simple_spinner_item, items).also {it.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)}- setSelection(choices.indexOf(Prefs.snoozeMinutes(this@SettingsActivity)).coerceAtLeast(0))- contentDescription = "Snooze length"+ setSelection(selected.coerceAtLeast(0))+ contentDescription = labelonItemSelectedListener = object : android.widget.AdapterView.OnItemSelectedListener {- override fun onItemSelected(parent: android.widget.AdapterView<*>?, view: View?, position: Int, id: Long) {- Prefs.setSnoozeMinutes(this@SettingsActivity, choices[position])- }+ override fun onItemSelected(parent: android.widget.AdapterView<*>?, view: View?, position: Int, id: Long) = onPick(position)override fun onNothingSelected(parent: android.widget.AdapterView<*>?) {}}})- section.addView(infoRow(row, "How long a snooze silences the alert sound and voice, like a radar detector's mute: the " +- "speaker button at the top of the main screen (tap it), Mute on an alert notification, and the car's snooze. " +- "Alerts still show on screen and in the list while snoozed. Long-press the speaker button for other lengths or " +- "to mute until you turn the sound back on.", "Snooze length"), at + 1)+ return row}/** Map > Re-center after, under Auto-recenter: how long after your last touch the map goes back to you. */diff --git a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt b/app/src/main/java/com/rfsentinel/app/util/Prefs.ktindex 69d91f7..e5a4ae5 100644--- a/app/src/main/java/com/rfsentinel/app/util/Prefs.kt+++ b/app/src/main/java/com/rfsentinel/app/util/Prefs.kt@@ -179,6 +179,13 @@ object Prefs {fun setSnoozeMinutes(context: Context, minutes: Int) = setInt(context, "snooze_minutes", minutes)val SNOOZE_CHOICES = listOf(5, 10, 15, 30, 60)+ /** What a swipe on a flagged row of the main list does, one of [SWIPE_ACTIONS]: right mutes and left hides by default. */+ fun swipeAction(context: Context, right: Boolean): String =+ (sp(context).getString(if (right) "swipe_right" else "swipe_left", null) ?: if (right) "mute" else "hide").takeIf { it in SWIPE_ACTIONS } ?: "none"+ fun setSwipeAction(context: Context, right: Boolean, action: String) =+ sp(context).edit { putString(if (right) "swipe_right" else "swipe_left", action) }+ val SWIPE_ACTIONS = listOf("mute", "hide", "none")+/** Muted, or snoozed for a while: no alert sound or voice. */fun alertsSilenced(context: Context, now: Long = System.currentTimeMillis()): Boolean =alertsMuted(context) || now < alertsSnoozedUntil(context)