@@ -19,6 +19,8 @@ package org.meshtastic.feature.map
1919
2020import android.Manifest // Added for Accompanist
2121import androidx.appcompat.content.res.AppCompatResources
22+ import androidx.compose.animation.Crossfade
23+ import androidx.compose.animation.core.tween
2224import androidx.compose.foundation.background
2325import androidx.compose.foundation.layout.Arrangement
2426import androidx.compose.foundation.layout.Box
@@ -32,10 +34,7 @@ import androidx.compose.foundation.layout.wrapContentHeight
3234import androidx.compose.foundation.layout.wrapContentWidth
3335import androidx.compose.foundation.rememberScrollState
3436import androidx.compose.foundation.verticalScroll
35- import androidx.compose.animation.Crossfade
36- import androidx.compose.animation.core.tween
3737import androidx.compose.material.icons.Icons
38- import androidx.compose.material.icons.filled.Close
3938import androidx.compose.material.icons.filled.Lens
4039import androidx.compose.material.icons.filled.LocationDisabled
4140import androidx.compose.material.icons.filled.PinDrop
@@ -52,7 +51,6 @@ import androidx.compose.material3.DropdownMenuItem
5251import androidx.compose.material3.ExperimentalMaterial3Api
5352import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
5453import androidx.compose.material3.Icon
55- import androidx.compose.material3.IconButton
5654import androidx.compose.material3.MaterialTheme
5755import androidx.compose.material3.Scaffold
5856import androidx.compose.material3.Surface
@@ -76,7 +74,6 @@ import androidx.compose.ui.platform.LocalDensity
7674import androidx.compose.ui.platform.LocalHapticFeedback
7775import androidx.compose.ui.unit.dp
7876import androidx.compose.ui.viewinterop.AndroidView
79- import androidx.compose.ui.window.DialogProperties
8077import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
8178import androidx.lifecycle.compose.collectAsStateWithLifecycle
8279import com.google.accompanist.permissions.ExperimentalPermissionsApi // Added for Accompanist
@@ -427,8 +424,7 @@ fun MapView(
427424 Timber .d(" mapStyleId from prefs: $id " )
428425 return CustomTileSource .getTileSource(id).also {
429426 zoomLevelMax = it.maximumZoomLevel.toDouble()
430- showDownloadButton =
431- if (it is OnlineTileSourceBase ) it.tileSourcePolicy.acceptsBulkDownload() else false
427+ showDownloadButton = if (it is OnlineTileSourceBase ) it.tileSourcePolicy.acceptsBulkDownload() else false
432428 }
433429 }
434430
@@ -464,18 +460,12 @@ fun MapView(
464460 MyLocationNewOverlay (this ).apply {
465461 enableMyLocation()
466462 enableFollowLocation()
467- getBitmapFromVectorDrawable(
468- context,
469- org.meshtastic.core.ui.R .drawable.ic_map_location_dot_24
470- )
463+ getBitmapFromVectorDrawable(context, org.meshtastic.core.ui.R .drawable.ic_map_location_dot_24)
471464 ?.let {
472465 setPersonIcon(it)
473466 setPersonAnchor(0.5f , 0.5f )
474467 }
475- getBitmapFromVectorDrawable(
476- context,
477- org.meshtastic.core.ui.R .drawable.ic_map_navigation_24
478- )?.let {
468+ getBitmapFromVectorDrawable(context, org.meshtastic.core.ui.R .drawable.ic_map_navigation_24)?.let {
479469 setDirectionIcon(it)
480470 setDirectionAnchor(0.5f , 0.5f )
481471 }
@@ -503,18 +493,14 @@ fun MapView(
503493 val waypoints by mapViewModel.waypoints.collectAsStateWithLifecycle(emptyMap())
504494
505495 val markerIcon = remember {
506- AppCompatResources .getDrawable(
507- context,
508- org.meshtastic.core.ui.R .drawable.ic_baseline_location_on_24
509- )
496+ AppCompatResources .getDrawable(context, org.meshtastic.core.ui.R .drawable.ic_baseline_location_on_24)
510497 }
511498
512499 fun MapView.onNodesChanged (nodes : Collection <Node >): List <MarkerWithLabel > {
513500 val nodesWithPosition = nodes.filter { it.validPosition != null }
514501 val ourNode = mapViewModel.ourNodeInfo.value
515502 val displayUnits = mapViewModel.config.display.units
516- val mapFilterStateValue =
517- mapViewModel.mapFilterStateFlow.value // Access mapFilterState directly
503+ val mapFilterStateValue = mapViewModel.mapFilterStateFlow.value // Access mapFilterState directly
518504 return nodesWithPosition.mapNotNull { node ->
519505 if (mapFilterStateValue.onlyFavorites && ! node.isFavorite && ! node.equals(ourNode)) {
520506 return @mapNotNull null
@@ -644,8 +630,7 @@ fun MapView(
644630 MarkerWithLabel (this , label, emoji).apply {
645631 id = " ${pt.id} "
646632 title = " ${pt.name} (${getUsername(waypoint.data.from)}$lock )"
647- snippet =
648- " [$time ] ${pt.description} " + stringResource(Res .string.expires) + " : $expireTimeStr "
633+ snippet = " [$time ] ${pt.description} " + stringResource(Res .string.expires) + " : $expireTimeStr "
649634 position = GeoPoint (pt.latitudeI * 1e- 7 , pt.longitudeI * 1e- 7 )
650635 setVisible(false ) // This seems to be always false, was this intended?
651636 setOnLongClickListener {
@@ -697,13 +682,7 @@ fun MapView(
697682
698683 // Only update osmdroid markers when using osmdroid
699684 if (! useMapLibre && map != null ) {
700- with (map) {
701- UpdateMarkers (
702- onNodesChanged(nodes),
703- onWaypointChanged(waypoints.values),
704- nodeClusterer
705- )
706- }
685+ with (map) { UpdateMarkers (onNodesChanged(nodes), onWaypointChanged(waypoints.values), nodeClusterer) }
707686 }
708687
709688 fun MapView.generateBoxOverlay () {
@@ -713,18 +692,13 @@ fun MapView(
713692 downloadRegionBoundingBox = boundingBox.zoomIn(zoomFactor)
714693 val polygon =
715694 Polygon ().apply {
716- points = Polygon .pointsAsRect(downloadRegionBoundingBox)
717- .map { GeoPoint (it.latitude, it.longitude) }
695+ points = Polygon .pointsAsRect(downloadRegionBoundingBox).map { GeoPoint (it.latitude, it.longitude) }
718696 }
719697 overlays.add(polygon)
720698 invalidate()
721699 val tileCount: Int =
722700 CacheManager (this )
723- .possibleTilesInArea(
724- downloadRegionBoundingBox,
725- zoomLevelMin.toInt(),
726- zoomLevelMax.toInt()
727- )
701+ .possibleTilesInArea(downloadRegionBoundingBox, zoomLevelMin.toInt(), zoomLevelMax.toInt())
728702 cacheEstimate = com.meshtastic.core.strings.getString(Res .string.map_cache_tiles, tileCount)
729703 }
730704
@@ -792,11 +766,12 @@ fun MapView(
792766 ) { isMapLibre ->
793767 if (isMapLibre) {
794768 // MapLibre implementation
795- timber.log.Timber .tag(" MapView" ).d(
796- " Calling MapLibrePOC with focusedNodeNum=%s, nodeTracks count=%d" ,
797- focusedNodeNum ? : " null" ,
798- nodeTracks?.size ? : 0
799- )
769+ timber.log.Timber .tag(" MapView" )
770+ .d(
771+ " Calling MapLibrePOC with focusedNodeNum=%s, nodeTracks count=%d" ,
772+ focusedNodeNum ? : " null" ,
773+ nodeTracks?.size ? : 0 ,
774+ )
800775 org.meshtastic.feature.map.maplibre.ui.MapLibrePOC (
801776 mapViewModel = mapViewModel,
802777 onNavigateToNodeDetails = navigateToNodeDetails,
@@ -834,8 +809,7 @@ fun MapView(
834809 )
835810 } else {
836811 Column (
837- modifier = Modifier .padding(top = 16 .dp, end = 16 .dp)
838- .align(Alignment .TopEnd ),
812+ modifier = Modifier .padding(top = 16 .dp, end = 16 .dp).align(Alignment .TopEnd ),
839813 verticalArrangement = Arrangement .spacedBy(8 .dp),
840814 ) {
841815 MapButton (
@@ -939,11 +913,11 @@ fun MapView(
939913 if (hasGps) {
940914 MapButton (
941915 icon =
942- if (myLocationOverlay == null ) {
943- Icons .Outlined .MyLocation
944- } else {
945- Icons .Default .LocationDisabled
946- },
916+ if (myLocationOverlay == null ) {
917+ Icons .Outlined .MyLocation
918+ } else {
919+ Icons .Default .LocationDisabled
920+ },
947921 contentDescription = stringResource(Res .string.toggle_my_position),
948922 onClick = {
949923 if (locationPermissionsState.allPermissionsGranted) {
@@ -1002,7 +976,6 @@ fun MapView(
1002976 }
1003977 }
1004978
1005-
1006979 showEditWaypointDialog?.let { waypoint ->
1007980 EditWaypointDialog (
1008981 waypoint = waypoint,
@@ -1011,12 +984,10 @@ fun MapView(
1011984 showEditWaypointDialog = null
1012985 mapViewModel.sendWaypoint(
1013986 waypoint.copy {
1014- if (id == 0 ) id =
1015- mapViewModel.generatePacketId() ? : return @EditWaypointDialog
987+ if (id == 0 ) id = mapViewModel.generatePacketId() ? : return @EditWaypointDialog
1016988 if (name == " " ) name = " Dropped Pin"
1017989 if (expire == 0 ) expire = Int .MAX_VALUE
1018- lockedTo =
1019- if (waypoint.lockedTo != 0 ) mapViewModel.myNodeNum ? : 0 else 0
990+ lockedTo = if (waypoint.lockedTo != 0 ) mapViewModel.myNodeNum ? : 0 else 0
1020991 if (waypoint.icon == 0 ) icon = 128205
1021992 },
1022993 )
@@ -1033,4 +1004,4 @@ fun MapView(
10331004 )
10341005 }
10351006 }
1036- }
1007+ }
0 commit comments