Skip to content

Commit 485a846

Browse files
jamesarichCopilot
andcommitted
fix: Resolve lint errors and warnings
- Wrap StateFlow.value read in remember{} to satisfy composition lint - Wrap derivedStateOf in remember{} (MapView PurgeTileSourceDialog) - Use mutableIntStateOf to avoid autoboxing (MapStyleDialog) - Use ResourcesCompat.getDrawable() instead of deprecated getDrawable() - Fix mixed indentation in MarkerClusterer.java Lint result: 0 errors, 10 warnings (down from 2 errors, 12 warnings) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 509b358 commit 485a846

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

androidApp/src/fdroid/java/org/meshtastic/app/map/cluster/MarkerClusterer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ protected void hideInfoWindows(){
127127
int zoomLevel = mapView.getZoomLevel();
128128
if (zoomLevel != mLastZoomLevel && !mapView.isAnimating()){
129129
hideInfoWindows();
130-
mClusters = clusterer(mapView);
131-
renderer(mClusters, canvas, mapView);
130+
mClusters = clusterer(mapView);
131+
renderer(mClusters, canvas, mapView);
132132
mLastZoomLevel = zoomLevel;
133133
}
134134

androidApp/src/fdroid/java/org/meshtastic/app/map/cluster/RadiusMarkerClusterer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import android.graphics.drawable.Drawable;
2828
import android.view.MotionEvent;
2929

30+
import androidx.core.content.res.ResourcesCompat;
31+
3032
import org.meshtastic.app.map.model.MarkerWithLabel;
3133

3234
import org.osmdroid.bonuspack.R;
@@ -72,7 +74,7 @@ public RadiusMarkerClusterer(Context ctx) {
7274
mTextPaint.setFakeBoldText(true);
7375
mTextPaint.setTextAlign(Paint.Align.CENTER);
7476
mTextPaint.setAntiAlias(true);
75-
Drawable clusterIconD = ctx.getResources().getDrawable(R.drawable.marker_cluster);
77+
Drawable clusterIconD = ResourcesCompat.getDrawable(ctx.getResources(), R.drawable.marker_cluster, ctx.getTheme());
7678
Bitmap clusterIcon = ((BitmapDrawable) clusterIconD).getBitmap();
7779
setIcon(clusterIcon);
7880
mAnimated = true;

androidApp/src/fdroid/kotlin/org/meshtastic/app/map/MapView.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import androidx.compose.runtime.derivedStateOf
5252
import androidx.compose.runtime.getValue
5353
import androidx.compose.runtime.mutableDoubleStateOf
5454
import androidx.compose.runtime.mutableFloatStateOf
55+
import androidx.compose.runtime.mutableIntStateOf
5556
import androidx.compose.runtime.mutableStateListOf
5657
import androidx.compose.runtime.mutableStateOf
5758
import androidx.compose.runtime.remember
@@ -825,15 +826,15 @@ private fun FdroidMainMapFilterDropdown(
825826

826827
@Composable
827828
private fun MapStyleDialog(selectedMapStyle: Int, onDismiss: () -> Unit, onSelectMapStyle: (Int) -> Unit) {
828-
val selected = remember { mutableStateOf(selectedMapStyle) }
829+
val selected = remember { mutableIntStateOf(selectedMapStyle) }
829830

830831
MapsDialog(onDismiss = onDismiss) {
831832
CustomTileSource.mTileSources.values.forEachIndexed { index, style ->
832833
ListItem(
833834
text = style,
834-
trailingIcon = if (index == selected.value) MeshtasticIcons.Check else null,
835+
trailingIcon = if (index == selected.intValue) MeshtasticIcons.Check else null,
835836
onClick = {
836-
selected.value = index
837+
selected.intValue = index
837838
onSelectMapStyle(index)
838839
onDismiss()
839840
},
@@ -886,7 +887,7 @@ private fun PurgeTileSourceDialog(onDismiss: () -> Unit) {
886887
val context = LocalContext.current
887888
val cache = SqlTileWriterExt()
888889

889-
val sourceList by derivedStateOf { cache.sources.map { it.source as String } }
890+
val sourceList by remember { derivedStateOf { cache.sources.map { it.source as String } } }
890891

891892
val selected = remember { mutableStateListOf<Int>() }
892893

androidApp/src/main/kotlin/org/meshtastic/app/ui/Main.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.compose.foundation.layout.safeDrawingPadding
2424
import androidx.compose.runtime.Composable
2525
import androidx.compose.runtime.LaunchedEffect
2626
import androidx.compose.runtime.getValue
27+
import androidx.compose.runtime.remember
2728
import androidx.compose.ui.Modifier
2829
import androidx.lifecycle.compose.collectAsStateWithLifecycle
2930
import androidx.navigation3.runtime.NavKey
@@ -57,12 +58,13 @@ fun MainScreen() {
5758
val viewModel: UIViewModel = koinViewModel()
5859
// Land on Connections for first-run / no-device-selected; otherwise on Nodes. Read synchronously
5960
// from the StateFlow (seeded from persisted prefs) so the initial tab is set in one shot.
60-
val initialTab =
61+
val initialTab = remember {
6162
if (viewModel.currentDeviceAddressFlow.value.isNullOrSelectedNone()) {
6263
TopLevelDestination.Connect.route
6364
} else {
6465
NodesRoute.Nodes
6566
}
67+
}
6668
val multiBackstack = rememberMultiBackstack(initialTab)
6769
val backStack = multiBackstack.activeBackStack
6870

0 commit comments

Comments
 (0)