Skip to content

Commit 262b530

Browse files
authored
feat: Add InternalUsageAttributionId documentation and opt out (#747)
* feat: Add InternalUsageAttributionId documentation and opt out This change adds documentation about the InternalUsageAttributionId and provides a means for the user to disable the attribution id. * feat: Moves attribution ID comments to the calling function kdoc * chore: more explanation for when to set the attributionId value. * docs: move internal usage attribution ID section
1 parent 3194c2a commit 262b530

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,13 @@ Box(Modifier.fillMaxSize()) {
497497

498498
The colors of the text, line, and shadow are also all configurable (e.g., based on `isSystemInDarkTheme()` on a dark map). Similarly, the `DisappearingScaleBar` animations can be configured.
499499

500+
## Internal usage attribution ID
501+
502+
This library calls the MapsApiSettings.addInternalUsageAttributionId method, which helps Google
503+
understand which libraries and samples are helpful to developers and is optional. Instructions for
504+
opting out of the identifier are provided in
505+
[reference documentation](maps-compose/src/main/java/com/google/maps/android/compose/internal/MapsApiAttribution.kt).
506+
500507
## Contributing
501508

502509
Contributions are welcome and encouraged! If you'd like to contribute, send us a [pull request] and refer to our [code of conduct] and [contributing guide].

maps-compose/src/main/java/com/google/maps/android/compose/internal/MapsApiAttribution.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,30 @@ internal object MapsApiAttribution {
2020
private val _isInitialized = mutableStateOf(false)
2121
val isInitialized: State<Boolean> = _isInitialized
2222

23+
/**
24+
* The value of the attribution ID. Set this to the empty string to opt out of attribution.
25+
*
26+
* This must be set before calling the GoogleMap composable.
27+
*/
28+
var attributionId: String = AttributionId.VALUE
29+
2330
/**
2431
* Adds the attribution ID to the Maps API settings. This is done on a background thread
2532
* using [Dispatchers.IO]. The attribution ID is only added once.
2633
*
34+
* Adds a usage attribution ID to the initializer, which helps Google understand which libraries
35+
* and samples are helpful to developers, such as usage of this library.
36+
* To opt out of sending the usage attribution ID, it is safe to delete this function call
37+
* or replace the value with an empty string.
38+
*
39+
* See https://developers.google.com/android/reference/com/google/android/gms/maps/MapsApiSettings#addInternalUsageAttributionId(android.content.Context,%20java.lang.String)
40+
*
2741
* @param context The context to use to add the attribution ID.
2842
*/
2943
suspend fun addAttributionId(context: Context) {
3044
if (hasBeenCalled.compareAndSet(false, true)) {
3145
withContext(Dispatchers.IO) {
32-
MapsApiSettings.addInternalUsageAttributionId(context, AttributionId.VALUE)
46+
MapsApiSettings.addInternalUsageAttributionId(context, attributionId)
3347
_isInitialized.value = true
3448
}
3549
}

0 commit comments

Comments
 (0)