Skip to content

Commit 45b0a9f

Browse files
committed
chore: corregir warnings de lint
- ModifierParameter: mover modifier al primer lugar en AppIconImage y MediaWidget - PrivateApi: suprimir en TwUtilAdapter (reflexión intencional para MCU) - StaticFieldLeak: suprimir en McuServiceLocator (applicationContext, no hay leak) - StaticFieldLeak: usar WeakReference en ReverseCameraActivity._instance - SetTextI18n: extraer strings hardcodeados a camera/res/values/strings.xml - DrawAllocation: pre-alocar RectF en RadarOverlayView en lugar de en onDraw
1 parent 8d8c8f3 commit 45b0a9f

7 files changed

Lines changed: 29 additions & 14 deletions

File tree

app/src/main/kotlin/dev/helm/launcher/ui/AppIconImage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ private val actionIconMap: Map<LauncherAction, ImageVector> = mapOf(
6363
fun AppIconImage(
6464
pkg: String,
6565
label: String,
66-
action: LauncherAction? = null,
6766
modifier: Modifier = Modifier,
67+
action: LauncherAction? = null,
6868
) {
6969
val icon = action?.let { actionIconMap[it] }
7070
if (icon != null) {

camera/src/main/kotlin/dev/helm/camera/RadarOverlayView.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class RadarOverlayView @JvmOverloads constructor(
2121
private var frontMax = 255
2222
private var rearMax = 255
2323

24+
private val drawRect = RectF()
25+
2426
private val safePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
2527
color = Color.GREEN
2628
style = Paint.Style.FILL
@@ -60,17 +62,17 @@ class RadarOverlayView @JvmOverloads constructor(
6062
// Front sensors — top of screen
6163
frontDistances.forEachIndexed { i, dist ->
6264
val paint = paintForDistance(dist)
63-
val rect = RectF(i * sensorW + 4f, 4f, (i + 1) * sensorW - 4f, barH)
64-
canvas.drawRoundRect(rect, 8f, 8f, paint)
65-
canvas.drawText("${dist}cm", rect.centerX(), rect.centerY() + labelPaint.textSize / 3, labelPaint)
65+
drawRect.set(i * sensorW + 4f, 4f, (i + 1) * sensorW - 4f, barH)
66+
canvas.drawRoundRect(drawRect, 8f, 8f, paint)
67+
canvas.drawText("${dist}cm", drawRect.centerX(), drawRect.centerY() + labelPaint.textSize / 3, labelPaint)
6668
}
6769

6870
// Rear sensors — bottom of screen
6971
rearDistances.forEachIndexed { i, dist ->
7072
val paint = paintForDistance(dist)
71-
val rect = RectF(i * sensorW + 4f, h - barH - 4f, (i + 1) * sensorW - 4f, h - 4f)
72-
canvas.drawRoundRect(rect, 8f, 8f, paint)
73-
canvas.drawText("${dist}cm", rect.centerX(), rect.centerY() + labelPaint.textSize / 3, labelPaint)
73+
drawRect.set(i * sensorW + 4f, h - barH - 4f, (i + 1) * sensorW - 4f, h - 4f)
74+
canvas.drawRoundRect(drawRect, 8f, 8f, paint)
75+
canvas.drawText("${dist}cm", drawRect.centerX(), drawRect.centerY() + labelPaint.textSize / 3, labelPaint)
7476
}
7577
}
7678

camera/src/main/kotlin/dev/helm/camera/ReverseCameraActivity.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import kotlinx.coroutines.cancel
1515
import kotlinx.coroutines.flow.launchIn
1616
import kotlinx.coroutines.flow.onEach
1717
import kotlinx.coroutines.launch
18+
import java.lang.ref.WeakReference
1819

1920
// Task 6.3/6.4/6.5/6.6/6.7/6.8 — full-screen reverse camera. Launched by ReverseCameraManager.
2021
// Back press is a no-op while in reverse; dismissed programmatically when gear changes.
@@ -33,7 +34,7 @@ class ReverseCameraActivity : Activity() {
3334
surfaceView = SurfaceView(this)
3435
radarOverlay = RadarOverlayView(this)
3536
noSignalBanner = TextView(this).apply {
36-
text = "Sin señal"
37+
text = getString(R.string.camera_no_signal)
3738
setTextColor(android.graphics.Color.WHITE)
3839
textSize = 18f
3940
gravity = android.view.Gravity.CENTER
@@ -51,7 +52,7 @@ class ReverseCameraActivity : Activity() {
5152
})
5253

5354
setContentView(root)
54-
_instance = this
55+
_instance = WeakReference(this)
5556

5657
if (!McuServiceLocator.isInitialized) {
5758
showStubMode()
@@ -90,7 +91,7 @@ class ReverseCameraActivity : Activity() {
9091
}
9192

9293
override fun onDestroy() {
93-
if (_instance === this) _instance = null
94+
if (_instance?.get() === this) _instance = null
9495
if (McuServiceLocator.isInitialized) {
9596
activityScope.launch { McuServiceLocator.service.send(0x0304, 0) }
9697
}
@@ -101,15 +102,15 @@ class ReverseCameraActivity : Activity() {
101102
// Task 6.7 — stub mode placeholder
102103
private fun showStubMode() {
103104
surfaceView.visibility = View.GONE
104-
noSignalBanner.text = "Cámara reversa — No disponible (Track B)"
105+
noSignalBanner.text = getString(R.string.camera_unavailable)
105106
noSignalBanner.visibility = View.VISIBLE
106107
}
107108

108109
companion object {
109-
@Volatile private var _instance: ReverseCameraActivity? = null
110+
@Volatile private var _instance: WeakReference<ReverseCameraActivity>? = null
110111

111112
fun requestDismiss() {
112-
_instance?.finish()
113+
_instance?.get()?.finish()
113114
}
114115
}
115116
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="camera_no_signal">Sin señal</string>
4+
<string name="camera_unavailable">Cámara reversa — No disponible (Track B)</string>
5+
</resources>

sdk/src/main/kotlin/dev/helm/sdk/McuServiceLocator.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.helm.sdk
22

3+
import android.annotation.SuppressLint
34
import android.content.Context
45
import android.os.Process
56
import kotlinx.coroutines.CoroutineScope
@@ -9,6 +10,8 @@ import kotlinx.coroutines.SupervisorJob
910
// Chooses TwUtilMcuDataSource when running as system UID; StubMcuDataSource otherwise.
1011
object McuServiceLocator {
1112

13+
// applicationContext is passed in — not a real leak.
14+
@SuppressLint("StaticFieldLeak")
1215
@Volatile private var _service: McuService? = null
1316

1417
val service: McuService

sdk/src/main/kotlin/dev/helm/sdk/TwUtilAdapter.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.helm.sdk
22

3+
import android.annotation.SuppressLint
34
import android.os.Handler
45
import android.os.Looper
56
import android.os.Message
@@ -9,6 +10,7 @@ import kotlinx.coroutines.flow.callbackFlow
910

1011
// Track B only. Reflective wrapper over android.tw.john.TWUtil (platform @hide class,
1112
// requires android.uid.system). Assumes TWUtil(Handler) constructor — verified post-FEL.
13+
@SuppressLint("PrivateApi")
1214
internal class TwUtilAdapter {
1315

1416
companion object {
@@ -149,6 +151,8 @@ internal class TwUtilAdapter {
149151
)
150152
}
151153

154+
// TODO [Track B / post-FEL]: if MCU doesn't send 0x010A proactively, discover the request
155+
// command byte via UART capture and call send() with it before waiting for this event.
152156
private fun parseMcuVersion(obj: Any?): McuEvent {
153157
val version = when (obj) {
154158
is ByteArray -> String(obj, Charsets.US_ASCII).trimEnd(' ')

widgets/src/main/kotlin/dev/helm/widgets/MediaWidget.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import androidx.compose.ui.unit.dp
1414

1515
@Composable
1616
fun MediaWidget(
17+
modifier: Modifier = Modifier,
1718
speed: Int = 0,
1819
title: String = "",
1920
artist: String = "",
20-
modifier: Modifier = Modifier,
2121
) {
2222
Column(modifier = modifier) {
2323
if (title.isNotEmpty()) {

0 commit comments

Comments
 (0)