Skip to content

Commit 6f6a5b4

Browse files
committed
Switch navigator to new beacon layer
Signed-off-by: Kyle Corry <kylecorry31@gmail.com>
1 parent 692cfff commit 6f6a5b4

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

app/src/main/java/com/kylecorry/trail_sense/tools/beacons/map_layers/BeaconGeoJsonSource.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ class BeaconGeoJsonSource : GeoJsonSource {
1616

1717
private var highlighted: Beacon? = null
1818
private var featureToBeaconMap = mapOf<GeoJsonFeature, Beacon>()
19+
private var outlineColor = Color.WHITE
1920

2021
fun highlight(beacon: Beacon?) {
2122
highlighted = beacon
2223
}
2324

25+
fun setOutlineColor(color: Int) {
26+
outlineColor = color
27+
}
28+
2429
private val beaconService = AppServiceRegistry.get<BeaconService>()
2530

2631
fun getBeacon(feature: GeoJsonFeature): Beacon? {
@@ -43,7 +48,7 @@ class BeaconGeoJsonSource : GeoJsonSource {
4348
it.id,
4449
it.name.trim(),
4550
color = it.color,
46-
strokeColor = Color.WHITE,
51+
strokeColor = outlineColor,
4752
opacity = if (highlighted == null || highlighted?.id == it.id) {
4853
255
4954
} else {

app/src/main/java/com/kylecorry/trail_sense/tools/beacons/map_layers/BeaconLayer.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class BeaconLayer(private val onBeaconClick: (beacon: Beacon) -> Boolean = { fal
2020
percentOpacity = prefs.opacity.get() / 100f
2121
}
2222

23+
fun setOutlineColor(color: Int){
24+
source.setOutlineColor(color)
25+
invalidate()
26+
}
27+
2328
fun highlight(beacon: Beacon?) {
2429
source.highlight(beacon)
2530
invalidate()

app/src/main/java/com/kylecorry/trail_sense/tools/navigation/ui/NavigatorFragment.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ class NavigatorFragment : BoundFragment<ActivityNavigatorBinding>() {
622622
}
623623

624624
// Update beacon layers
625-
layers.setBeacons(nearbyBeacons)
626625
beaconCompassLayer.setBeacons(nearbyBeacons)
627626
beaconCompassLayer.highlight(destinationBeacon)
628627
layers.setDestination(destinationBeacon)

app/src/main/java/com/kylecorry/trail_sense/tools/navigation/ui/layers/NavigationCompassLayerManager.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import com.kylecorry.trail_sense.shared.map_layers.ui.layers.MyLocationLayerMana
2121
import com.kylecorry.trail_sense.shared.map_layers.ui.layers.TiledMapLayer
2222
import com.kylecorry.trail_sense.shared.sensors.SensorService
2323
import com.kylecorry.trail_sense.tools.beacons.domain.Beacon
24-
import com.kylecorry.trail_sense.tools.beacons.map_layers.LegacyBeaconLayer
24+
import com.kylecorry.trail_sense.tools.beacons.map_layers.BeaconLayer
2525
import com.kylecorry.trail_sense.tools.paths.map_layers.PathLayer
2626
import com.kylecorry.trail_sense.tools.paths.map_layers.PathLayerManager
2727
import com.kylecorry.trail_sense.tools.photo_maps.infrastructure.tiles.PhotoMapRegionLoader
@@ -33,7 +33,7 @@ import com.kylecorry.trail_sense.tools.tides.map_layers.TideMapLayerManager
3333
class NavigationCompassLayerManager {
3434
private val taskRunner = MapLayerBackgroundTask()
3535
private val pathLayer = PathLayer()
36-
private val beaconLayer = LegacyBeaconLayer()
36+
private val beaconLayer = BeaconLayer()
3737
private val myLocationLayer = MyLocationLayer()
3838
private val tideLayer = TideMapLayer()
3939
private val photoMapLayer = TiledMapLayer()
@@ -138,10 +138,6 @@ class NavigationCompassLayerManager {
138138
layerManager?.onBoundsChanged(bounds)
139139
}
140140

141-
fun setBeacons(beacons: List<Beacon>) {
142-
beaconLayer.setBeacons(beacons)
143-
}
144-
145141
fun setDestination(beacon: Beacon?) {
146142
beaconLayer.highlight(beacon)
147143
}

0 commit comments

Comments
 (0)