Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ad4b89e66 | |||
| 2a2eb9f4af |
@@ -12,8 +12,8 @@ android {
|
||||
applicationId = "org.soulstone.overwatch"
|
||||
minSdk = 26
|
||||
targetSdk = 35
|
||||
versionCode = 9
|
||||
versionName = "0.2.0"
|
||||
versionCode = 11
|
||||
versionName = "0.2.2"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -40,6 +40,13 @@
|
||||
|
||||
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true" />
|
||||
|
||||
<!-- Allow Intent.setPackage("com.google.android.apps.maps") on Android 11+
|
||||
(package visibility) so we can force "Open in Maps" pins to land in
|
||||
Google Maps regardless of the user's default geo: handler. -->
|
||||
<queries>
|
||||
<package android:name="com.google.android.apps.maps" />
|
||||
</queries>
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
|
||||
@@ -92,6 +92,14 @@ class MainActivity : ComponentActivity() {
|
||||
val maxScore by DetectionService.store.maxScore.collectAsState()
|
||||
val mapPoints by DetectionService.mapPoints.collectAsState()
|
||||
val userLocation by DetectionService.location.collectAsState()
|
||||
// Visible map radius = max of the two proximity sliders
|
||||
// so the user sees the full area where a detection
|
||||
// can fire. Using the raw setting values regardless of
|
||||
// enabled-state keeps the visualization stable when a
|
||||
// source is briefly toggled.
|
||||
val deflockProx by settings.deflockProximityM.collectAsState()
|
||||
val citizenProx by settings.citizenProximityM.collectAsState()
|
||||
val mapRadiusM = maxOf(deflockProx, citizenProx).toFloat()
|
||||
val granted by permissionsGranted
|
||||
val denied by permanentlyDenied
|
||||
|
||||
@@ -108,6 +116,7 @@ class MainActivity : ComponentActivity() {
|
||||
events = events,
|
||||
mapPoints = mapPoints,
|
||||
userLocation = userLocation,
|
||||
mapRadiusMeters = mapRadiusM,
|
||||
canStart = true,
|
||||
permissionMessage = message,
|
||||
showOpenAppSettings = denied && !granted,
|
||||
|
||||
@@ -44,6 +44,17 @@ class DetectionStore(
|
||||
_maxScore.value = 0
|
||||
}
|
||||
|
||||
/** Drop every event from a single source — used when a proximity threshold
|
||||
* changes and the owning scanner needs to re-emit a fresh slate (events
|
||||
* outside the new radius would otherwise linger until their 5-min TTL). */
|
||||
@Synchronized
|
||||
fun clearSource(source: DetectionSource) {
|
||||
val remaining = _events.value.filter { it.source != source }
|
||||
if (remaining.size == _events.value.size) return
|
||||
_events.value = remaining
|
||||
recompute(remaining)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun pruneExpired() {
|
||||
val cutoff = nowMs() - retentionMs
|
||||
|
||||
@@ -99,15 +99,36 @@ class CitizenScanner(
|
||||
// Drop cache entries that no longer appear in the trending list (resolved).
|
||||
incidentCache.keys.retainAll(ids.toSet())
|
||||
|
||||
// Fetch any ids we haven't seen yet — Citizen incidents don't mutate,
|
||||
// so a single fetch per id per session is enough.
|
||||
for (id in ids) {
|
||||
if (incidentCache[id] == null) {
|
||||
client.fetchIncident(id)?.also { incidentCache[id] = it }
|
||||
}
|
||||
}
|
||||
|
||||
emitProximityEvents(fix, ids.mapNotNull { incidentCache[it] })
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-evaluate the cached incident set against the current proximity + age
|
||||
* thresholds and the latest fix, *without* a network refetch. Used when
|
||||
* the user moves the proximity slider — events outside a tightened radius
|
||||
* would otherwise linger and detections inside a widened radius wouldn't
|
||||
* appear until the next poll cycle.
|
||||
*/
|
||||
fun refresh() {
|
||||
val fix = locationProvider.location.value ?: return
|
||||
store.clearSource(DetectionSource.CITIZEN)
|
||||
emitProximityEvents(fix, incidentCache.values.toList())
|
||||
}
|
||||
|
||||
private fun emitProximityEvents(fix: Location, incidents: Collection<CitizenClient.Incident>) {
|
||||
val now = System.currentTimeMillis()
|
||||
val limit = proximityMeters()
|
||||
val out = FloatArray(1)
|
||||
|
||||
for (id in ids) {
|
||||
val incident = incidentCache[id] ?: client.fetchIncident(id)?.also {
|
||||
incidentCache[id] = it
|
||||
} ?: continue
|
||||
|
||||
for (incident in incidents) {
|
||||
// Title-based pre-filter: drop pure fire/medical events.
|
||||
if (FIRE_MEDICAL_RX.containsMatchIn(incident.title) &&
|
||||
!POLICE_TITLE_RX.containsMatchIn(incident.title)) {
|
||||
|
||||
@@ -101,6 +101,27 @@ class DeflockScanner(
|
||||
}
|
||||
}
|
||||
}
|
||||
emitProximityEvents(fix)
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-evaluate the cached ALPRs against the current proximity threshold and
|
||||
* the latest fix, *without* a network refetch. Used when the user moves the
|
||||
* proximity slider — the slider changes [proximityMeters], but the scanner
|
||||
* is otherwise idle (no new location ticks while stationary), so events
|
||||
* outside the new radius would otherwise linger and detections inside the
|
||||
* widened radius wouldn't appear until the next handleFix cycle.
|
||||
*
|
||||
* Clears the DEFLOCK source from the store first so events that fall
|
||||
* outside a tightened radius disappear immediately.
|
||||
*/
|
||||
fun refresh() {
|
||||
val fix = locationProvider.location.value ?: return
|
||||
store.clearSource(DetectionSource.DEFLOCK)
|
||||
emitProximityEvents(fix)
|
||||
}
|
||||
|
||||
private fun emitProximityEvents(fix: Location) {
|
||||
val points = _cachedPoints.value
|
||||
if (points.isEmpty()) return
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.launch
|
||||
import org.soulstone.overwatch.MainActivity
|
||||
import org.soulstone.overwatch.R
|
||||
@@ -108,6 +109,8 @@ class DetectionService : LifecycleService() {
|
||||
private var observerJob: Job? = null
|
||||
private var mapPointsJob: Job? = null
|
||||
private var locationJob: Job? = null
|
||||
private var deflockProxJob: Job? = null
|
||||
private var citizenProxJob: Job? = null
|
||||
private var bleStarted = false
|
||||
private var wifiStarted = false
|
||||
private var deflockStarted = false
|
||||
@@ -229,6 +232,22 @@ class DetectionService : LifecycleService() {
|
||||
locationJob = lifecycleScope.launch {
|
||||
locationProvider.location.collect { _location.value = it }
|
||||
}
|
||||
|
||||
// Live re-eval when the user moves a proximity slider. drop(1) skips
|
||||
// the StateFlow's initial replay so we don't redundantly clear+re-emit
|
||||
// the events the scanner just produced from its first handleFix call.
|
||||
deflockProxJob?.cancel()
|
||||
if (deflockStarted) {
|
||||
deflockProxJob = lifecycleScope.launch {
|
||||
settings.deflockProximityM.drop(1).collect { deflockScanner.refresh() }
|
||||
}
|
||||
}
|
||||
citizenProxJob?.cancel()
|
||||
if (citizenStarted) {
|
||||
citizenProxJob = lifecycleScope.launch {
|
||||
settings.citizenProximityM.drop(1).collect { citizenScanner.refresh() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun endScanning() {
|
||||
@@ -247,6 +266,8 @@ class DetectionService : LifecycleService() {
|
||||
observerJob?.cancel(); observerJob = null
|
||||
mapPointsJob?.cancel(); mapPointsJob = null
|
||||
locationJob?.cancel(); locationJob = null
|
||||
deflockProxJob?.cancel(); deflockProxJob = null
|
||||
citizenProxJob?.cancel(); citizenProxJob = null
|
||||
_mapPoints.value = emptyList()
|
||||
_location.value = null
|
||||
lastNotifiedTier = ThreatLevel.GREEN
|
||||
|
||||
@@ -41,6 +41,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
@@ -53,8 +54,9 @@ import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.math.cos
|
||||
import org.osmdroid.tileprovider.tilesource.TileSourceFactory
|
||||
import org.osmdroid.util.BoundingBox
|
||||
import org.osmdroid.util.GeoPoint
|
||||
import org.osmdroid.views.MapView
|
||||
import org.osmdroid.views.overlay.Marker
|
||||
@@ -74,6 +76,10 @@ fun MainScreen(
|
||||
events: List<DetectionEvent>,
|
||||
mapPoints: List<DeflockClient.AlprPoint>,
|
||||
userLocation: Location?,
|
||||
/** Visible radius of the map circle, in meters. Driven by the larger of
|
||||
* the DeFlock and Citizen proximity sliders so the user sees the full
|
||||
* area where a detection could fire. */
|
||||
mapRadiusMeters: Float,
|
||||
onStartStop: () -> Unit,
|
||||
onOpenSettings: () -> Unit,
|
||||
canStart: Boolean,
|
||||
@@ -90,12 +96,12 @@ fun MainScreen(
|
||||
.background(MaterialTheme.colorScheme.background)
|
||||
.padding(horizontal = 24.dp)
|
||||
) {
|
||||
Row(
|
||||
// Box (rather than Row + SpaceBetween) so the title is truly centered
|
||||
// regardless of the gear icon's width.
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 8.dp),
|
||||
verticalAlignment = Alignment.Top,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
.padding(top = 8.dp)
|
||||
) {
|
||||
Text(
|
||||
text = "OVERWATCH",
|
||||
@@ -103,9 +109,13 @@ fun MainScreen(
|
||||
fontSize = 26.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontFamily = FontFamily.Monospace,
|
||||
letterSpacing = 4.sp
|
||||
letterSpacing = 4.sp,
|
||||
modifier = Modifier.align(Alignment.Center)
|
||||
)
|
||||
IconButton(onClick = onOpenSettings) {
|
||||
IconButton(
|
||||
onClick = onOpenSettings,
|
||||
modifier = Modifier.align(Alignment.CenterEnd)
|
||||
) {
|
||||
Icon(
|
||||
Icons.Filled.Settings,
|
||||
contentDescription = "Settings",
|
||||
@@ -125,6 +135,7 @@ fun MainScreen(
|
||||
animating = running,
|
||||
userLocation = userLocation,
|
||||
mapPoints = mapPoints,
|
||||
mapRadiusMeters = mapRadiusMeters,
|
||||
onTap = { showSheet = true }
|
||||
)
|
||||
|
||||
@@ -213,12 +224,37 @@ fun MainScreen(
|
||||
}
|
||||
}
|
||||
|
||||
/** Builds a small filled-circle Marker icon. Used for both the user-position
|
||||
* dot (blue) and the ALPR pins (red) — osmdroid's default teardrop marker
|
||||
* reads as a "click me" affordance which is wrong for a non-interactive
|
||||
* visualization, so we use simple dots instead. */
|
||||
private fun dotDrawable(
|
||||
resources: android.content.res.Resources,
|
||||
sizePx: Int,
|
||||
coreColor: Int
|
||||
): android.graphics.drawable.BitmapDrawable {
|
||||
val bitmap = android.graphics.Bitmap.createBitmap(
|
||||
sizePx, sizePx, android.graphics.Bitmap.Config.ARGB_8888
|
||||
)
|
||||
val canvas = android.graphics.Canvas(bitmap)
|
||||
val outline = android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG).apply {
|
||||
color = 0xFFFFFFFF.toInt()
|
||||
}
|
||||
canvas.drawCircle(sizePx / 2f, sizePx / 2f, sizePx / 2f - 1f, outline)
|
||||
val core = android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG).apply {
|
||||
color = coreColor
|
||||
}
|
||||
canvas.drawCircle(sizePx / 2f, sizePx / 2f, sizePx / 2f - 4f, core)
|
||||
return android.graphics.drawable.BitmapDrawable(resources, bitmap)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ThreatMapCircle(
|
||||
level: ThreatLevel,
|
||||
animating: Boolean,
|
||||
userLocation: Location?,
|
||||
mapPoints: List<DeflockClient.AlprPoint>,
|
||||
mapRadiusMeters: Float,
|
||||
onTap: () -> Unit
|
||||
) {
|
||||
val idleColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
@@ -278,69 +314,83 @@ private fun ThreatMapCircle(
|
||||
)
|
||||
}
|
||||
} else {
|
||||
// OSM map snapshot, centered on the user, with red ALPR pins.
|
||||
// Non-interactive — touches are captured by the click overlay above
|
||||
// so a tap opens the source-details bottom sheet (matching the old
|
||||
// circle's UX). Pan/zoom controls stay off.
|
||||
// OSM map snapshot, centered on the user, with red ALPR pins and
|
||||
// a blue user-position dot. Non-interactive — touches are captured
|
||||
// by the click overlay above, so a tap opens the source-details
|
||||
// bottom sheet. Pan/zoom controls stay off.
|
||||
// Capture into a local non-null val so the AndroidView update
|
||||
// lambda doesn't run afoul of smart-cast-into-closure rules.
|
||||
val fix: Location = userLocation
|
||||
val ctx = LocalContext.current
|
||||
// Build the marker drawables once per Composition rather than
|
||||
// every recomposition — bitmap allocation isn't free.
|
||||
val userDot = remember(ctx) { dotDrawable(ctx.resources, 36, 0xFF2196F3.toInt()) }
|
||||
val flockDot = remember(ctx) { dotDrawable(ctx.resources, 26, 0xFFD7263D.toInt()) }
|
||||
AndroidView(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
factory = { ctx ->
|
||||
MapView(ctx).apply {
|
||||
factory = { c ->
|
||||
MapView(c).apply {
|
||||
setTileSource(TileSourceFactory.MAPNIK)
|
||||
setMultiTouchControls(false)
|
||||
setBuiltInZoomControls(false)
|
||||
isClickable = false
|
||||
isFocusable = false
|
||||
controller.setZoom(17.0)
|
||||
}
|
||||
},
|
||||
update = { map ->
|
||||
map.controller.setCenter(GeoPoint(fix.latitude, fix.longitude))
|
||||
map.overlays.clear()
|
||||
|
||||
// ALPR dots first, user dot last so the user draws on top.
|
||||
for (p in mapPoints) {
|
||||
val m = Marker(map).apply {
|
||||
position = GeoPoint(p.lat, p.lon)
|
||||
setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM)
|
||||
title = p.operator ?: p.manufacturer ?: "ALPR"
|
||||
// Disable osmdroid's per-marker info popup since
|
||||
// the map isn't interactive — the bottom sheet is
|
||||
// the canonical "details" surface.
|
||||
map.overlays.add(
|
||||
Marker(map).apply {
|
||||
position = GeoPoint(p.lat, p.lon)
|
||||
setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_CENTER)
|
||||
icon = flockDot
|
||||
title = p.operator ?: p.manufacturer ?: "ALPR"
|
||||
setInfoWindow(null)
|
||||
}
|
||||
)
|
||||
}
|
||||
map.overlays.add(
|
||||
Marker(map).apply {
|
||||
position = GeoPoint(fix.latitude, fix.longitude)
|
||||
setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_CENTER)
|
||||
icon = userDot
|
||||
setInfoWindow(null)
|
||||
}
|
||||
map.overlays.add(m)
|
||||
}
|
||||
)
|
||||
|
||||
// Fit the visible radius to the larger of the two proximity
|
||||
// settings. Defer to map.post so the call lands after layout
|
||||
// — zoomToBoundingBox needs measured dimensions to compute
|
||||
// the right zoom level. Latitude-aware longitude scaling so
|
||||
// the bbox stays roughly square in real meters at any lat.
|
||||
val r = mapRadiusMeters.toDouble().coerceAtLeast(50.0)
|
||||
val latDegPerMeter = 1.0 / 111_000.0
|
||||
val lonDegPerMeter = 1.0 /
|
||||
(111_000.0 * cos(Math.toRadians(fix.latitude)).coerceAtLeast(0.01))
|
||||
val bbox = BoundingBox(
|
||||
fix.latitude + r * latDegPerMeter,
|
||||
fix.longitude + r * lonDegPerMeter,
|
||||
fix.latitude - r * latDegPerMeter,
|
||||
fix.longitude - r * lonDegPerMeter
|
||||
)
|
||||
map.post { map.zoomToBoundingBox(bbox, false, 0) }
|
||||
map.invalidate()
|
||||
},
|
||||
onRelease = { map -> map.onDetach() }
|
||||
)
|
||||
// Threat-tier scrim — pulses while scanning, dims tiles to keep
|
||||
// the dark theme aesthetic and signals tier without text.
|
||||
val scrimAlpha = (0.35f * pulse).coerceIn(0.18f, 0.5f)
|
||||
// Threat-tier scrim — pulses while scanning. Heavier alpha than
|
||||
// the first cut so the tier color reads at a glance over OSM
|
||||
// tiles, which are themselves cream/light by default.
|
||||
val scrimAlpha = (0.55f * pulse).coerceIn(0.40f, 0.65f)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(activeColor.copy(alpha = scrimAlpha))
|
||||
)
|
||||
// Tier label, top-center. Smaller than the old text so the map
|
||||
// remains readable underneath.
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(top = 14.dp),
|
||||
contentAlignment = Alignment.TopCenter
|
||||
) {
|
||||
Text(
|
||||
text = level.name,
|
||||
color = Color.White,
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.Black,
|
||||
fontFamily = FontFamily.Monospace,
|
||||
letterSpacing = 2.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
// Click capture sits on top so taps reach onTap regardless of which
|
||||
// visual layer was painted underneath.
|
||||
@@ -395,6 +445,14 @@ private fun SourcesPanel(events: List<DetectionEvent>) {
|
||||
}
|
||||
}
|
||||
|
||||
/** User-facing label for a detection source. The internal enum stays MIC
|
||||
* (mic-bearing devices is the technical concept) while the UI shows the
|
||||
* friendlier "COMMERCIAL" — Nest/Ring/Echo are commercial smart-home gear. */
|
||||
private fun DetectionSource.displayLabel(): String = when (this) {
|
||||
DetectionSource.MIC -> "COMMERCIAL"
|
||||
else -> name
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SourceRow(source: DetectionSource, events: List<DetectionEvent>) {
|
||||
val health by SourceHealth.flowFor(source).collectAsState()
|
||||
@@ -414,7 +472,7 @@ private fun SourceRow(source: DetectionSource, events: List<DetectionEvent>) {
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = source.name,
|
||||
text = source.displayLabel(),
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
@@ -483,23 +541,22 @@ private fun EventRow(e: DetectionEvent) {
|
||||
if (e.hasGeo) {
|
||||
IconButton(
|
||||
onClick = {
|
||||
// resolveActivity returns null on Android 11+ without a matching
|
||||
// <queries> entry even when Google Maps is installed. Skip the
|
||||
// pre-check and let startActivity handle it; catch the rare
|
||||
// "no app at all" case instead of silently no-op'ing.
|
||||
val uri = Uri.parse("geo:${e.lat},${e.lon}?q=${e.lat},${e.lon}(${Uri.encode(e.label)})")
|
||||
val intent = Intent(Intent.ACTION_VIEW, uri).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
// Force the pin to open in Google Maps rather than whichever
|
||||
// app holds the user's default geo: handler — Waze, etc. can
|
||||
// intercept geo: intents and we don't want that here. Falls
|
||||
// back to a generic browser intent if Maps isn't installed.
|
||||
val mapsUri = Uri.parse(
|
||||
"https://www.google.com/maps/search/?api=1&query=${e.lat},${e.lon}"
|
||||
)
|
||||
val mapsIntent = Intent(Intent.ACTION_VIEW, mapsUri)
|
||||
.setPackage("com.google.android.apps.maps")
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
try {
|
||||
ctx.startActivity(intent)
|
||||
ctx.startActivity(mapsIntent)
|
||||
} catch (_: android.content.ActivityNotFoundException) {
|
||||
// Fall back to a Google Maps URL — works even on devices
|
||||
// without a registered geo: handler.
|
||||
val webUri = Uri.parse(
|
||||
"https://www.google.com/maps/search/?api=1&query=${e.lat},${e.lon}"
|
||||
)
|
||||
val webIntent = Intent(Intent.ACTION_VIEW, webUri)
|
||||
val fallback = Intent(Intent.ACTION_VIEW, mapsUri)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
try { ctx.startActivity(webIntent) } catch (_: android.content.ActivityNotFoundException) {}
|
||||
try { ctx.startActivity(fallback) } catch (_: android.content.ActivityNotFoundException) {}
|
||||
}
|
||||
},
|
||||
modifier = Modifier.size(28.dp)
|
||||
|
||||
@@ -83,7 +83,7 @@ fun SettingsScreen(
|
||||
SourceToggle("WIFI • WiFi BSSID + SSID", wifi) { settings.setWifiEnabled(it) }
|
||||
SourceToggle("DEFLOCK • ALPR map (Overpass)", deflock) { settings.setDeflockEnabled(it) }
|
||||
SourceToggle("CITIZEN • Real-time incident feed", citizen) { settings.setCitizenEnabled(it) }
|
||||
SourceToggle("MIC • Smart speakers / cams (Echo, Ring, Nest)", mic) { settings.setMicEnabled(it) }
|
||||
SourceToggle("COMMERCIAL • Nest, Ring, Echo", mic) { settings.setMicEnabled(it) }
|
||||
Spacer(Modifier.height(8.dp))
|
||||
if (isRunning) {
|
||||
Button(
|
||||
@@ -167,11 +167,16 @@ private fun SourceToggle(label: String, value: Boolean, onChange: (Boolean) -> U
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
// weight(1f) reserves the remaining row width for the label so it
|
||||
// wraps on narrow screens instead of clipping under the Switch.
|
||||
Text(
|
||||
text = label,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
fontSize = 14.sp,
|
||||
fontFamily = FontFamily.Monospace
|
||||
fontFamily = FontFamily.Monospace,
|
||||
modifier = Modifier
|
||||
.weight(1f, fill = true)
|
||||
.padding(end = 12.dp)
|
||||
)
|
||||
Switch(checked = value, onCheckedChange = onChange)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user