diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-07-02 02:04:40 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-07-02 02:04:40 +0000 |
| commit | d0164358d2f449d40f7c79149dccfdd5bfa79d7f (patch) | |
| tree | a044e7ce83c452eade419d74f1d99cc2b4513003 /android-app/app/src/main | |
| parent | 1893aee8e9a23fdc51e203c918f52374fa601d7d (diff) | |
fix(ui): quit X icon, FAB visibility, sheet border, blank map layers
- Remove ic_close icon from Quit App button (fragment_safety.xml)
- fab_fishing now hides/shows in showOverlay/showTrackDetail/hideOverlays
so fishing+record FABs always move together and disappear on non-map pages
- Add strokeWidth=0dp to instrument bottom sheet card to remove gray border
- Fix blank map: split addToStyleBuilder into addSourcesToStyleBuilder
(builder time) + addBaseLayersToStyle (inserts at index 0, below OFM
vector layers) + addOverlayLayersToStyle (appends above OFM labels).
Previously withLayer() appended rasters after OFM layers so the opaque
Ocean base covered all labels/roads.
- Add Log.d tracing throughout style load + layer insertion for debugging
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'android-app/app/src/main')
4 files changed, 46 insertions, 31 deletions
diff --git a/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt b/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt index dd14557..ead98ae 100644 --- a/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt +++ b/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt @@ -481,6 +481,7 @@ class MainActivity : AppCompatActivity(), SafetyFragment.SafetyListener { overlayShowing = true fragmentContainer.visibility = View.VISIBLE fabRecordTrack.visibility = View.GONE + fabFishing.visibility = View.GONE fabLayers.visibility = View.GONE fabRecenter.visibility = View.GONE supportFragmentManager.beginTransaction() @@ -496,6 +497,7 @@ class MainActivity : AppCompatActivity(), SafetyFragment.SafetyListener { overlayShowing = true fragmentContainer.visibility = View.VISIBLE fabRecordTrack.visibility = View.GONE + fabFishing.visibility = View.GONE fabLayers.visibility = View.GONE fabRecenter.visibility = View.GONE supportFragmentManager.beginTransaction() @@ -508,6 +510,7 @@ class MainActivity : AppCompatActivity(), SafetyFragment.SafetyListener { overlayShowing = false fragmentContainer.visibility = View.GONE fabRecordTrack.visibility = View.VISIBLE + fabFishing.visibility = View.VISIBLE fabLayers.visibility = View.VISIBLE val following = mapHandler?.isFollowing?.value ?: true fabRecenter.visibility = if (following) View.GONE else View.VISIBLE @@ -679,9 +682,13 @@ class MainActivity : AppCompatActivity(), SafetyFragment.SafetyListener { val styleBuilder = Style.Builder() .fromUri("https://tiles.openfreemap.org/styles/bright") - layerManager.addToStyleBuilder(styleBuilder) + layerManager.addSourcesToStyleBuilder(styleBuilder) + android.util.Log.d("MapLayers", "setStyle starting") maplibreMap.setStyle(styleBuilder) { style -> + android.util.Log.d("MapLayers", "style loaded: ${style.layers.size} layers, ${style.sources.size} sources") + layerManager.addBaseLayersToStyle(style) + layerManager.addOverlayLayersToStyle(style) loadedStyleFlow.value = style val anchorBitmap = rasterizeDrawable(R.drawable.ic_anchor) val arrowBitmap = rasterizeDrawable(R.drawable.ic_tidal_arrow) diff --git a/android-app/app/src/main/kotlin/org/terst/nav/ui/MapLayerManager.kt b/android-app/app/src/main/kotlin/org/terst/nav/ui/MapLayerManager.kt index b8b7ac8..f6ee4fb 100644 --- a/android-app/app/src/main/kotlin/org/terst/nav/ui/MapLayerManager.kt +++ b/android-app/app/src/main/kotlin/org/terst/nav/ui/MapLayerManager.kt @@ -102,66 +102,74 @@ class MapLayerManager(context: Context) { } /** - * Registers all raster sources and layers into [Style.Builder]. - * Layer order (bottom → top): ocean → satellite → charts → wind → sst → depth → seamarks. - * MapHandler's vector layers go on top after the style loads. + * Registers all raster SOURCES into [builder] — no layers. + * + * Layers must be injected into a live [Style] after load: + * - [addBaseLayersToStyle] inserts base-map rasters at index 0 (below OFM vector layers) + * - [addOverlayLayersToStyle] appends overlay rasters on top of OFM labels + * + * builder.withLayer() appends AFTER all OFM layers, so base rasters would cover labels — + * that's why we defer layer insertion to after style load. */ - fun addToStyleBuilder(builder: Style.Builder) { - // ── Sources ─────────────────────────────────────────────────────────── + fun addSourcesToStyleBuilder(builder: Style.Builder) { builder.withSource(RasterSource(SOURCE_OCEAN, TileSet("2.2.0", URL_OCEAN).also { it.setMaxZoom(13f) }, 256)) - builder.withSource(RasterSource(SOURCE_SATELLITE, TileSet("2.2.0", URL_SATELLITE), 256)) - builder.withSource(RasterSource(SOURCE_CHARTS, TileSet("2.2.0", URL_CHARTS), 256)) - builder.withSource(RasterSource(SOURCE_WIND, TileSet("2.2.0", URL_WIND), 256)) - builder.withSource(RasterSource(SOURCE_SEAMARKS, TileSet("2.2.0", URL_SEAMARKS).also { it.setMaxZoom(18f) }, 256)) - builder.withSource(RasterSource(SOURCE_DEPTH, TileSet("2.2.0", URL_DEPTH).also { it.setMinZoom(3f); it.setMaxZoom(18f) }, 256)) - builder.withSource(RasterSource(SOURCE_SST, TileSet("2.2.0", URL_SST), 256)) + } - // ── Layers (bottom → top within raster stack) ───────────────────────── - builder.withLayer(RasterLayer(LAYER_OCEAN, SOURCE_OCEAN).apply { + /** + * Inserts base-map rasters at indices 0/1/2 so OFM vector layers sit on top. + * Call this immediately after the style finishes loading. + */ + fun addBaseLayersToStyle(style: Style) { + android.util.Log.d("MapLayers", "addBaseLayersToStyle preset=$basePreset ofmLayers=${style.layers.size}") + // Insert in ascending index order so final order from bottom is: ocean(0) → satellite(1) → charts(2) → OFM… + style.addLayerAt(RasterLayer(LAYER_OCEAN, SOURCE_OCEAN).apply { setProperties(PropertyFactory.rasterOpacity(1f)) setProperties(PropertyFactory.visibility(visibilityFor(basePreset, LAYER_OCEAN))) - }) - - builder.withLayer(RasterLayer(LAYER_SATELLITE, SOURCE_SATELLITE).apply { + }, 0) + style.addLayerAt(RasterLayer(LAYER_SATELLITE, SOURCE_SATELLITE).apply { setProperties(PropertyFactory.rasterOpacity(1f)) setProperties(PropertyFactory.visibility(visibilityFor(basePreset, LAYER_SATELLITE))) - }) - - builder.withLayer(RasterLayer(LAYER_CHARTS, SOURCE_CHARTS).apply { + }, 1) + style.addLayerAt(RasterLayer(LAYER_CHARTS, SOURCE_CHARTS).apply { setProperties(PropertyFactory.rasterOpacity(opacityFor(basePreset))) setProperties(PropertyFactory.visibility(visibilityFor(basePreset, LAYER_CHARTS))) - }) + }, 2) + android.util.Log.d("MapLayers", "base layers inserted, ocean=${visibilityFor(basePreset, LAYER_OCEAN)} satellite=${visibilityFor(basePreset, LAYER_SATELLITE)}") + } - builder.withLayer(RasterLayer(LAYER_WIND, SOURCE_WIND).apply { + /** + * Appends overlay rasters on top of the full OFM + base-map stack. + * These are semi-transparent so OFM labels remain readable underneath. + */ + fun addOverlayLayersToStyle(style: Style) { + android.util.Log.d("MapLayers", "addOverlayLayersToStyle wind=$windEnabled seamarks=$seamarksEnabled depth=$depthEnabled sst=$sstEnabled") + style.addLayer(RasterLayer(LAYER_WIND, SOURCE_WIND).apply { setProperties(PropertyFactory.rasterOpacity(0.85f)) setProperties(PropertyFactory.visibility(if (windEnabled) "visible" else "none")) }) - - builder.withLayer(RasterLayer(LAYER_SST, SOURCE_SST).apply { + style.addLayer(RasterLayer(LAYER_SST, SOURCE_SST).apply { setProperties(PropertyFactory.rasterOpacity(0.65f)) setProperties(PropertyFactory.visibility(if (sstEnabled) "visible" else "none")) }) - - // Depth contours sit below seamarks so soundings don't obscure nav aid symbols - builder.withLayer(RasterLayer(LAYER_DEPTH, SOURCE_DEPTH).apply { + // Depth below seamarks so soundings don't obscure nav aid symbols + style.addLayer(RasterLayer(LAYER_DEPTH, SOURCE_DEPTH).apply { setProperties(PropertyFactory.rasterOpacity(0.85f)) setProperties(PropertyFactory.visibility(if (depthEnabled) "visible" else "none")) }) - - builder.withLayer(RasterLayer(LAYER_SEAMARKS, SOURCE_SEAMARKS).apply { + style.addLayer(RasterLayer(LAYER_SEAMARKS, SOURCE_SEAMARKS).apply { setProperties(PropertyFactory.visibility(if (seamarksEnabled) "visible" else "none")) }) } diff --git a/android-app/app/src/main/res/layout/activity_main.xml b/android-app/app/src/main/res/layout/activity_main.xml index fc60c80..ed1b7ce 100644 --- a/android-app/app/src/main/res/layout/activity_main.xml +++ b/android-app/app/src/main/res/layout/activity_main.xml @@ -127,6 +127,7 @@ app:behavior_hideable="false" app:behavior_peekHeight="120dp" app:cardElevation="16dp" + app:strokeWidth="0dp" app:shapeAppearance="@style/ShapeAppearance.Nav.BottomSheet" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"> diff --git a/android-app/app/src/main/res/layout/fragment_safety.xml b/android-app/app/src/main/res/layout/fragment_safety.xml index 2c06431..78f8754 100644 --- a/android-app/app/src/main/res/layout/fragment_safety.xml +++ b/android-app/app/src/main/res/layout/fragment_safety.xml @@ -35,8 +35,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Quit App" - android:textColor="?attr/colorOnSurfaceVariant" - app:icon="@drawable/ic_close" /> + android:textColor="?attr/colorOnSurfaceVariant" /> </LinearLayout> |
