Skip to content

Commit eeb7da7

Browse files
pengdevgithub-actions[bot]
authored andcommitted
[compose] Improved reliability of attribution list updates on source change. (#9965)
Fixes https://mapbox.atlassian.net/browse/MAPSAND-2527 ## Problem Before mapbox/mapbox-sdk#9411, there was no reliable way to detect when map attributions changed. This affected scenarios where: - Sources are added at runtime. - Standard styles are loaded with dynamic sources. - Style imports modify attributions. Since internal style source details are not exposed through public APIs, the attribution UI could become stale and show incorrect licensing information. ## Solution This PR utilizes the new `StyleAttributionsChangedCallback` introduced in mapbox/mapbox-sdk#9411 as the source of truth for attribution changes. This ensures the attribution list UI updates correctly in all scenarios, including edge cases not covered by the previous implementation. ## Changes - Integrated `StyleAttributionsChangedCallback` to listen for attribution changes. - Updated attribution list refresh logic to trigger on callback events. - Improved reliability of attribution display in the Compose extension. GitOrigin-RevId: adebb9f8aa3174c3bfc6bfe53e5e793a6e9f66fb
1 parent 01ff918 commit eeb7da7

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Mapbox welcomes participation and contributions from everyone.
1414

1515
## Bug fixes 🐞
1616
* Fixed a potential leak of animators, which resulted in the absence of MapIdle events.
17+
* [compose] Improved reliability of attribution list updates on source change.
1718

1819
# 11.18.1 January 29, 2026
1920
## Dependencies

extension-compose/src/main/java/com/mapbox/maps/extension/compose/ornaments/attribution/MapAttributionScope.kt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import com.mapbox.common.Cancelable
5252
import com.mapbox.common.geofencing.GeofencingError
5353
import com.mapbox.maps.MapView
5454
import com.mapbox.maps.SourceDataLoadedType
55+
import com.mapbox.maps.StyleAttributionsChangedCallback
5556
import com.mapbox.maps.extension.compose.MapboxMapScopeMarker
5657
import com.mapbox.maps.extension.compose.R
5758
import com.mapbox.maps.extension.compose.ornaments.attribution.internal.AttributionComposePlugin
@@ -656,22 +657,25 @@ public class MapAttributionScope internal constructor(
656657

657658
// Refresh the attributions when style changes, as for Standard style, the source events are hidden
658659
DisposableEffect(plugin) {
659-
var styleDataLoadedCancelable: Cancelable? = null
660+
var styleAttributionChangedCancelable: Cancelable? = null
660661
if (plugin != null) {
661662
// Refresh the attribution initially to show the Mapbox telemetry, feedback attributions etc, even without source attributions
662663
updateAttributionState(mapView, plugin)
663-
// Update attributions when style data is loaded
664-
styleDataLoadedCancelable = mapView.mapboxMap.subscribeStyleDataLoaded {
665-
logD(
666-
TAG,
667-
"AttributionComposePlugin(${plugin.hashCode()}) style loaded, refresh attributions"
668-
)
669-
updateAttributionState(mapView, plugin)
670-
}
664+
// Update attributions when style attribution is changed
665+
// Used internal styleManager API to utlise this new StyleAttributionsChanged event.
666+
styleAttributionChangedCancelable = mapView.mapboxMap.styleManager.subscribe(
667+
StyleAttributionsChangedCallback {
668+
logD(
669+
TAG,
670+
"AttributionComposePlugin(${plugin.hashCode()}) StyleAttributionsChanged, refresh attributions"
671+
)
672+
updateAttributionState(mapView, plugin)
673+
}
674+
)
671675
}
672676
onDispose {
673-
styleDataLoadedCancelable?.cancel()
674-
styleDataLoadedCancelable = null
677+
styleAttributionChangedCancelable?.cancel()
678+
styleAttributionChangedCancelable = null
675679
}
676680
}
677681

0 commit comments

Comments
 (0)